quiver_log 1.0.6

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 #

API Docs are available.

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.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  quiver_log: ^1.0.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:quiver_log/log.dart';
import 'package:quiver_log/web.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
51
Overall:
Weighted score of the above. [more]
75
Learn more about scoring.

We analyzed this package on Aug 18, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: web

Platform components identified in package: html.

Health suggestions

Format lib/log.dart.

Run dartfmt to format lib/log.dart.

Format lib/src/log.dart.

Run dartfmt to format lib/src/log.dart.

Format lib/src/web.dart.

Run dartfmt to format lib/src/web.dart.

Format lib/web.dart.

Run dartfmt to format lib/web.dart.

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 2 dependencies without version constraints. Specify version ranges for the following dependencies: intl, logging.

Documentation URL is insecure. (-5 points)

Update the documentation field and use a secure (https) URL.

The package description is too short. (-4 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and quiver_log.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.2.4 <3.0.0
intl >=0.9.9 0.15.8
logging >=0.9.0 0.11.3+2
Transitive dependencies
path 1.6.4
Dev dependencies
test >=0.12.13