remote_logger 0.3.0+2 remote_logger: ^0.3.0+2 copied to clipboard
A listener for logging library to post logs to remote storage.
Dart library for posting logs to a remote storage. Use together with logging
library.
Features #
- ✅ Post log message to remote server
- ✅ Provide custom headers
- ✅ Override request body
- ✅ Retry on errors with exponential timeout
- ❌ TODO: cache/store information locally
Usage #
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.
Logger.root.onRecord.listen(remoteLogger);
// Log a message.
logger.info('Test message');
}
Additional information #
Please file feature requests and bugs at the issue tracker.