remote_logger 0.3.0+2 copy "remote_logger: ^0.3.0+2" to clipboard
remote_logger: ^0.3.0+2 copied to clipboard

A listener for logging library to post logs to remote storage.

example/remote_logger_example.dart

// ignore_for_file: prefer-correct-test-file-name

import 'package:logging/logging.dart';
import 'package:remote_logger/remote_logger.dart';

void main() {
  Logger.root.level = Level.ALL;

  final logger = Logger('TestLogger');

  // Create remote logger.
  final remoteLogger = RemoteLogger(
    url: Uri.parse('http://example.com'),
    // Optionally, override the body of the request.
    getBody: (record, body) => <String, dynamic>{
      ...body,
      'level': record.level.toString(),
    },
    // Optionally, provide additional headers.
    getHeaders: (headers) => <String, String>{
      ...headers,
      'X-License-Key': 'TEST_KEY',
    },
  );

  // Set remoteLogger as a listener.
  // ignore: avoid-unassigned-stream-subscriptions, assign is not needed
  Logger.root.onRecord.listen(remoteLogger.call);

  // Log a message.
  logger.info('Test message');
}
3
likes
160
points
20
downloads

Publisher

verified publishermews.com

Weekly Downloads

A listener for logging library to post logs to remote storage.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

async, http, logging, meta

More

Packages that depend on remote_logger