Git Product home page Git Product logo

quiver-log's Introduction

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 Formatter {
  String call(LogRecord record) => record.message;
}

main() {
  var logger = Logger('quiver.TestLogger');
  var appender = InMemoryListAppender(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.

To create a new kind of Appender simply extend Appender. To create a new Formatter just implement the Formatter abstract class. Take a look at PrintAppender and BasicLogFormatter for an example.

Making Changes and Running Tests

All patches must be formatted using dartfmt and submitted with tests. To run the tests use:

dart run test test/all_tests.dart

dart run test -p chrome test/all_web_tests.dart

quiver-log's People

Contributors

adambender avatar cbracken avatar chrisbwright avatar davidmorgan avatar srawlins avatar vadimtsushko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quiver-log's Issues

Const loggers and log closures

Enhancement requests:

  1. Support const loggers. These are loggers that can have their methods code stripped.
  2. Support logging closures to remove unnecessary/expensive string interpolation when the log statement wont actually execute:
    log.noise(() => "$foo$bar$baz"); <- string is never interpolated if log's current level > noise.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.