Registers a delegate method for log messages callbacks.

Namespace: Sfs2X
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.3.0 (1.7.3)

Syntax

C#
public void AddLogListener(
	LogLevel logLevel,
	EventListenerDelegate eventListener
)

Parameters

logLevel
Type: Sfs2X.Logging..::..LogLevel
The level of the log events to register a listener for.
eventListener
Type: EventListenerDelegate
The event listener to register.

Remarks

Calling this method is just like calling the Logger.AddEventListener method directly, but in addition the Logger.EnableEventDispatching property is automatically set to true.

Examples

 Copy imageCopy
void SomeMethod() {
    sfs.AddLogListener(LogLevel.INFO, OnInfoLogMessage);
    sfs.AddLogListener(LogLevel.WARN, OnWarnLogMessage);
}
void OnInfoLogMessage(BaseEvent evt) {
    string message = (string)evt.Params["message"];
    Console.WriteLine("[SFS2X INFO] " + message);                       // .Net / Unity
    System.Diagnostics.Debug.WriteLine("[SFS2X INFO] " + message);      // Windows Universal
}
void OnWarnLogMessage(BaseEvent evt) {
    string message = (string)evt.Params["message"];
    Console.WriteLine("[SFS2X WARN] " + message);                       // .Net / Unity
    System.Diagnostics.Debug.WriteLine("[SFS2X WARN] " + message);      // Windows Universal
}

See Also