logger_io

Last updated:

0 purchases

logger_io Image
logger_io Images
Add to Cart

Description:

logger io

A Simple logger that does what a logger should do: send your input messages to a series of outputs.
Logger io #

Usage #
Simple #
final logger = Logger();

logger.d('debug message');
logger.i('info message');
logger.s('success message');
logger.w('warning message');
logger.e('error', stackTrace: StackTrace.current);
copied to clipboard
Multiple outputs #
final logger = Logger(
outputs: [
ConsoleOutput(),
ExampleCrashlyticsOutput(),
],
);
copied to clipboard
Define your output #
Just implement the output class. For example, below is an example crashlytics output.
class ExampleCrashlyticsOutput implements Output {
final FirebaseCrashlytics _crashlytics;

const ExampleCrashlyticsOutput(this._crashlytics);

@override
void log({
required Object? message,
required Level level,
required StackTrace? stackTrace,
required String context,
}) {
if (level.value >= Level.error.value) {
_crashlytics.recordError(message, stackTrace ?? StackTrace.current);
} else {
_crashlytics.log(message.toString());
}
}
}
copied to clipboard
Performance #
It is faster than a library like logger because it does not use the stack trace
for every log (only if specified). This results in faster logging when no stack trace is used.
Durations for logger_io, 20 debug log (5 times): (1 ms, 2 ms, 2 ms, 1 ms, 2 ms)
Duration for logger, 20 debug log (5 times): (15 ms, 16 ms, 16 ms, 16 ms, 13 ms)
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.