Legacy Documentation: Version 2018.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Logger

class in UnityEngine

/

Implemented in:UnityEngine.CoreModule


Implements interfaces:ILogger, ILogHandler

Description

Initializes a new instance of the Logger.

Create a new instance or use default Debug.unityLogger. See Also: ILogger, ILogHandler.

#pragma strict
public class MyLogHandler implements ILogHandler {
	public function LogFormat(logType: LogType, context: UnityEngine.Object, format: String, args: Object[]) {
		Debug.unityLogger.logHandler.LogFormat(logType, context, format, args);
	}
	public function LogException(exception: Exception, context: UnityEngine.Object) {
		Debug.unityLogger.LogException(exception, context);
	}
}
public class MyGameClass extends MonoBehaviour {
	private static var kTAG: String = "MyGameTag";
	private var myLogger: Logger;
	function Start() {
		myLogger = new Logger(new MyLogHandler());
		myLogger.Log(kTAG, "MyGameClass Start.");
	}
}

Properties

filterLogTypeTo selective enable debug log message.
logEnabledTo runtime toggle debug logging [ON/OFF].
logHandlerSet Logger.ILogHandler.

Constructors

LoggerCreate a custom Logger.

Public Methods

IsLogTypeAllowedCheck logging is enabled based on the LogType.
LogLogs message to the Unity Console using default logger.
LogErrorA variant of Logger.Log that logs an error message.
LogExceptionA variant of Logger.Log that logs an exception message.
LogFormatLogs a formatted message.
LogWarningA variant of Logger.Log that logs an warning message.

Did you find this page useful? Please give it a rating: