logging_utils 1.1.0 copy "logging_utils: ^1.1.0" to clipboard
logging_utils: ^1.1.0 copied to clipboard

A package for logging with more extensive options than the built in logger.

example/logging_utils_example.dart

import 'package:logging_utils/logging_utils.dart';

void main() async {
  // simply using predefined logger

  logging.setLoggerSinkLevel(LogLevel.INFO);
  logging.setDateTimeFMT(DateTimeFMT.TIME);
  logging.start();
  // ...
  logging.info("info");
  logging.critical("critical");
  // ...
  await logging.stop();

  // or using a user-configured logger

  final Logger logger = Logger(
      loggerName: "MAIN",
      sink:
          FileSink(filename: "log.txt", behavior: FileSinkStartBehavior.CLEAR),
      loggerCallback: null);
  logger.setFlushInterval(100);
  logger.setDateTimeFMT(DateTimeFMT.DATE);
  logger.setLoggerSinkLevel(LogLevel.ERROR);
  logger.start();
  // ...
  logger.info("info");
  logger.critical("critical");
  // ...
  await logger.stop();

  // same available with a threaded logger

  ThreadedLogger tlogger = ThreadedLogger(
      loggerName: "MAIN", sink: ConsoleSink(), loggerCallback: null);
  // note that starting a ThreadedLogger needs to be awaited
  await tlogger.start();
  // ...
  tlogger.warning("warning");
  tlogger.critical("critical");
  // ...
  tlogger.setLoggerSink(
      FileSink(filename: "a.log", behavior: FileSinkStartBehavior.CLEAR));
  tlogger.setDateTimeFMT(DateTimeFMT.TS_US);
  tlogger.setLoggerName("CHILD");
  tlogger.setLoggerSinkLevel(LogLevel.ERROR);
  // ...
  tlogger.info("info");
  tlogger.critical("critical");
  // ...
  await tlogger.stop();
}
2
likes
160
points
31
downloads

Publisher

unverified uploader

Weekly Downloads

A package for logging with more extensive options than the built in logger.

Repository (GitHub)
View/report issues

Topics

#debugging #logging

Documentation

API reference

License

MIT (license)

More

Packages that depend on logging_utils