Skip to content

Latest commit

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

CustomDebugLogger

UnityUnity.NetLICENSE
DebugLog

Table of Contents


Description

Add custom processing before being displayed in the console using Debug.Log, Debug.LogWarning, Debug.LogError, etc.

Installation

Install from Unity Package Manager.

  • Window -> Package Manager
  • "+" -> Add package from git URL...
    https://github.com/ADONE-Games/CustomDebugLogger.git?path=/Assets/LogSystem

Function structure

classDiagram
direction TB
class ILogHandler {
<<interface>>
+ LogFormat(LogType, UnityEngine.Object, string, params object[]): ~void~
+ LogException(Exception, Object): ~void~
}
class ILogger {
<<interface>>
+ logHandler : ~ILogHandler~
}
class Debug {
+ Log(string): ~void~
+ Log(string, UnityEngine.Object): ~void~
+ LogWarning(string): ~void~
+ LogWarning(string, UnityEngine.Object): ~void~
+ LogError(string): ~void~
+ LogError(string, UnityEngine.Object): ~void~
}
class Logger{
+ logHandler[ LoggerEventManager ] : ILogHandler
}
class IDisposable {
<<interface>>
+ Dispose(): ~void~
}
class ILoggerEvent {
<<interface>>
}
class LoggerEventManager {
- OriginalDebugLogHandler[ DebugLogHandler ] : ~ILogHandler~
+ LogForamt(LogType, UnityEngine.Object, string, params object[]): ~void~
+ LogException(Exception, UnityEngine.Object): ~void~
}
class LoggerSetup {
+ Initialize(params LoggerEventFactory[]): ~AbstractLoggerEvent~
}
class AbstractLoggerEvent {
<<abstract>>
# OriginalDebugLogHandler : ~ILogHandler~
+ LogForamt(LogType, UnityEngine.Object, string, params object[])*: abstract ~void~
+ LogException(Exception, UnityEngine.Object)*: abstract ~void~
+ Dispose(): virtual ~void~
}
class ConsoleLoggerEvent {
+ LogForamt(LogType, UnityEngine.Object, string, params object[]): ~void~
+ LogException(Exception, UnityEngine.Object): ~void~
}
class FileLoggerEvent {
+ LogForamt(LogType, UnityEngine.Object, string, params object[]): ~void~
+ LogException(Exception, UnityEngine.Object): ~void~
}
class AbstractLoggerController{
<<abstract>>
# Prefix : abstract ~string~ + Log(string)$ : ~void~
+ Log(string, UnityEngine.Color32)$ : ~void~
+ LogWarning(string)$ : ~void~
+ LogWarning(string, UnityEngine.Color32)$ : ~void~
+ LogError(string)$ : ~void~
}
class ConsoleLoggerController{
# Prefix : ~string~
}
class DebugLogHandler [ "DebugLogHandler : < ILogHandler>" ]
class console
class FileOutput
ILogHandler <|-- Logger
ILogHandler <|-- ILogger
ILogger <|-- Logger
Debug --> Logger
ILogHandler <|-- ILoggerEvent
IDisposable <|-- ILoggerEvent
ILoggerEvent <|-- AbstractLoggerEvent
ILoggerEvent <|-- LoggerEventManager
Logger --> LoggerEventManager
LoggerEventManager *-- LoggerSetup
LoggerSetup <-- AbstractLoggerEvent
AbstractLoggerEvent <|.. ConsoleLoggerEvent
AbstractLoggerEvent <|.. FileLoggerEvent
FileLoggerEvent --> FileOutput
ConsoleLoggerEvent --> DebugLogHandler
DebugLogHandler --> console
AbstractLoggerEvent"use" -- DebugLogHandler
Debug <-- ConsoleLoggerController : Send Debug.Log / Debug.LogWarning / Debug.LogError messages
AbstractLoggerController <|-- ConsoleLoggerController
Loading
The original structure of the Debug.Log series
classDiagram
direction TB
class ILogHandler {
<<interface>>
+ LogFormat(LogType, UnityEngine.Object, string, params object[]): ~void~
+ LogException(Exception, UnityEngine.Object): ~void~
}
class ILogger {
<<interface>>
+ logHandler : ~ILogHandler~
}
class Debug {
+ Log(string): ~void~
+ Log(string, UnityEngine.Object): ~void~
+ LogWarning(string): ~void~
+ LogWarning(string, UnityEngine.Object): ~void~
+ LogError(string): ~void~
+ LogError(string, UnityEngine.Object): ~void~
}
class Logger{
+ logHandler[DebugLogHandler] : ~ILogHandler~
}
class DebugLogHandler [ "DebugLogHandler : ~ILogHandler~" ]
class console
ILogHandler <|-- Logger
ILogHandler <|-- ILogger
ILogger <|-- Logger
Debug --> Logger
Logger --> DebugLogHandler
DebugLogHandler --> console
Loading

Usage

Create your own class inheriting from ADONEGames.CustomDebugLogger.AbstractLoggerEvent.
Specify it using ADONEGames.CustomDebugLogger.LoggerSetup.Initialize( params LoggerEventFactory[] ).


Initialize

Example 1

publicclassLoggerTest:MonoBehaviour{privatevoidStart(){LoggerSetup.Initialize( handler =>newConsoleLoggerEvent(handler), handler =>newFileLoggerEvent(handler));}}

Example 2

publicclassLoggerTest{// Auto-start before the splash scene[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]privatestaticvoidInitialize(){LoggerSetup.Initialize( handler =>newConsoleLoggerEvent(handler), handler =>newFileLoggerEvent(handler));}}

Run

publicclassButtonTrigger:MonoBehaviour{publicvoidOnClick_NormalDebugLog(){Debug.Log("Button Clicked!");}publicvoidOnClick_CustomDebugLog(){MyClassLoggerController.Log("ボタン クリック!",Color.magenta);}}
CustomDebugLogger_DemoPlay.mov

Provided Event Functionality

ADONEGames.CustomDebugLogger
AbstractLoggerEventAbstract class for additional processing
ADONEGames.CustomDebugLogger
ConsoleLoggerEventConsole displayInherit from AbstractLoggerEvent
FileLoggerEventFile outputInherit from AbstractLoggerEvent

Registering Events

ADONEGames.CustomDebugLogger
LoggerSetup-Initialization Class
-Initialize(params LoggerEventFactory[])Registration of additional processing
LoggerSetup.Initialize( handler =>newConsoleLoggerEvent(handler), handler =>newFileLoggerEvent(handler));

Provided Controller Functionality

ADONEGames.CustomDebugLogger
AbstractLoggerControllerAbstract class for the controller
ADONEGames.CustomDebugLogger
ConsoleLoggerControllerConsole displayInherit from AbstractLoggerController
ConsoleLoggerController.Log("Hello World!");ConsoleLoggerController.Log("Hello World!",newColor32(255,255,255,255));ConsoleLoggerController.LogWarning("Hello World!");ConsoleLoggerController.LogWarning("Hello World!",newColor32(255,255,255,255));ConsoleLoggerController.LogError("Hello World!");

License

This software is released under the MIT License.
You are free to use it within the bounds of the license.
When using it, please include the following copyright and license notices.

LICENSE


About

Unity DebugLog

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages