setLoggerProvider static method

Future<void> setLoggerProvider(
  1. LoggerProvider provider
)

Static method that permits to configure the logging system used by the library.

The logging system must respect the LoggerProvider interface. A custom class can be used to wrap any third-party logging system.
If no logging system is specified, all the generated log is discarded.
The following categories are available to be consumed:

  • lightstreamer.stream:
    logs socket activity on Lightstreamer Server connections;
    at INFO level, socket operations are logged;
    at DEBUG level, read/write data exchange is logged.
  • lightstreamer.protocol:
    logs requests to Lightstreamer Server and Server answers;
    at INFO level, requests are logged;
    at DEBUG level, request details and events from the Server are logged.
  • lightstreamer.session:
    logs Server Session lifecycle events;
    at INFO level, lifecycle events are logged;
    at DEBUG level, lifecycle event details are logged.
  • lightstreamer.subscriptions:
    logs subscription requests received by the clients and the related updates;
    at WARN level, alert events from the Server are logged;
    at INFO level, subscriptions and unsubscriptions are logged;
    at DEBUG level, requests batching and update details are logged.
  • lightstreamer.actions:
    logs settings / API calls.
  • provider A LoggerProvider instance that will be used to generate log messages by the library classes.

Implementation

static Future<void> setLoggerProvider(LoggerProvider provider) async {
  var logger = provider.getLogger('lightstreamer');
  var level = logger.isDebugEnabled() ? ConsoleLogLevel.DEBUG
            : logger.isErrorEnabled() ? ConsoleLogLevel.ERROR
            : logger.isWarnEnabled()  ? ConsoleLogLevel.WARN
            : logger.isInfoEnabled()  ? ConsoleLogLevel.INFO
            : logger.isFatalEnabled() ? ConsoleLogLevel.FATAL
            : ConsoleLogLevel.TRACE;
  var arguments = <String, dynamic>{
    'level': level,
    'provider': provider.runtimeType.toString()
  };
  LogManager.setLoggerProvider(provider);
  return await NativeBridge.instance.invokeMethod('LightstreamerClient.setLoggerProvider', arguments);
}