Click or drag to resize

LoggerAddEventListener Method

Registers a delegate method for log messages callbacks.

Namespace:  Sfs2X.Logging
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public void AddEventListener(
	LogLevel level,
	EventListenerDelegate listener
)

Parameters

level
Type: Sfs2X.LoggingLogLevel
The level of the log events to register a listener for.
listener
Type: EventListenerDelegate
The event listener to register.
Remarks
Calling this method is just like calling the SmartFox.AddLogListener method.
Examples
void SomeMethod() {
    sfs.logger.EnableEventDispatching = true;
    sfs.Logger.AddEventListener(LogLevel.INFO, OnInfoLogMessage);
    sfs.Logger.AddEventListener(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