quiver_log 1.0.4 copy "quiver_log: ^1.0.4" to clipboard
quiver_log: ^1.0.4 copied to clipboard

outdated

A logging utility for Dart, part of the quiver utilities

Quiver Log #

Quiver log is a set of logging utilities that make it easy to configure and manage Dart's built in logging capabilities.

Documentation #

http://google.github.io/quiver-log/

The Basics #

Dart's built-in logging utilities are fairly low level. This means each time you start a new project you have to copy/paste a bunch of logging configuration code to setup output locations and logging formats. Quiver-log provides a set of higher-level abstractions to make it easier to get logging setup correctly. Specifically, there are two new concepts: appender and formatter. Appenders define output locations like the console, http or even in-memory data structures that can store logs. Formatters, as the name implies, allow for custom logging formats.

Here is a simple example that sets up a InMemoryAppender with a SimpleStringFormatter:

import 'package:logging/logging.dart';
import 'package:quiver_log/log.dart';

class SimpleStringFormatter implements FormatterBase<String> {
  String call(LogRecord record) => record.message;
}

main() {
  var logger = new Logger('quiver.TestLogger');
  var appender = new InMemoryListAppender(new SimpleStringFormatter());
  appender.attachLogger(logger);
}

That's all there is to it!

Quiver-log provides three Appenders: PrintAppender which uses Dart's print statement to write to the console, InMemoryListAppender which writes logs to a simple list (this can be useful for debugging or testing) and a WebAppender which will take advantage of web console methods to improve readability in your browser. Additionally, a single Formatter called BasicLogFormatter is included and uses a "MMyy HH:mm:ss.S" format. Of course there is no limit to what kind of appenders you can create, we have plans to add appenders HTTP, WebSocket, DOM, Isolate and SysOut.

To create a new kind of Appender simply extends Appender. To create a new Formatter just implement the Formatter typedef or FormatterBase class if you need to hold state in your formtatter. Take a look at PrintAppender and BasicLogFormatter for an example.

5
likes
0
pub points
60%
popularity

Publisher

unverified uploader

A logging utility for Dart, part of the quiver utilities

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

intl, logging

More

Packages that depend on quiver_log