Registers a delegate method for log messages callbacks.

Namespace: Sfs2X.Logging
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.0.0 (1.7.0)

Syntax

C#
public void AddEventListener(
	LogLevel level,
	EventListenerDelegate listener
)

Parameters

level
Type: Sfs2X.Logging..::..LogLevel
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

 Copy imageCopy
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);          // 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