mars_logging
An integration which records logs from the
logging package into
mars.
Status: Experimental
NOTE: This package is published as a development prerelease
(1.0.0-dev.5) to solicit feedback. The API surface is expected to change —
potentially in breaking ways — before the stable 1.0.0 release.
Usage
Add both mars and mars_logging as dependencies. This package does not
re-export the Mars API, so import package:mars alongside it to configure the
logger; attach the integration once, typically at startup:
import 'package:logging/logging.dart';
import 'package:mars/mars.dart';
import 'package:mars_logging/mars_logging.dart';
void main() {
xlog.open(
logsDir: '/path/to/logs',
cacheDir: '/path/to/logs/cache',
);
Logger.root.onRecord.listen(xlog.onRecord);
Logger('MyApp').info('hello');
Logger('MyApp').severe('something failed', error, stackTrace);
xlog.close();
}
Level mapping
package:logging levels map to Mars log levels as:
package:logging |
Mars XLog |
|---|---|
ALL / FINEST / FINER / FINE |
verbose |
CONFIG |
debug |
INFO |
info |
WARNING |
warn |
SEVERE |
error |
SHOUT |
fatal |
A record's loggerName becomes the xlog tag; error and stackTrace, when
present, are appended to the message.
See the mars package README for XLog
configuration (compression, encryption, rotation), flushing, and offline
decoding. A complete runnable example is available in
example/mars_logging_example.dart.
Bugs and feedback
Please file issues in the bug tracker.
Libraries
- mars_logging
package:loggingintegration for Mars.