Click or drag to resize

SmartFoxAddLogListener Method

Registers a delegate method for log messages callbacks.

Namespace:  Sfs2X
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public void AddLogListener(
	LogLevel logLevel,
	EventListenerDelegate eventListener
)

Parameters

logLevel
Type: Sfs2X.LoggingLogLevel
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
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);      // UWP
}

void OnWarnLogMessage(BaseEvent evt) {
    string message = (string)evt.Params["message"];
    Console.WriteLine("[SFS2X WARN] " + message);                       // .Net / Unity
    System.Diagnostics.Debug.WriteLine("[SFS2X WARN] " + message);      // UWP
}
See Also