platform/packages/pretty_logging
Tobe O cf8e83552a Add 'packages/pretty_logging/' from commit 'd5150f9dee0969e66af0aecae17d0bbdaf2b44cf'
git-subtree-dir: packages/pretty_logging
git-subtree-mainline: a13d02069e
git-subtree-split: d5150f9dee
2020-02-15 18:28:16 -05:00
..
example Add 'packages/pretty_logging/' from commit 'd5150f9dee0969e66af0aecae17d0bbdaf2b44cf' 2020-02-15 18:28:16 -05:00
lib Add 'packages/pretty_logging/' from commit 'd5150f9dee0969e66af0aecae17d0bbdaf2b44cf' 2020-02-15 18:28:16 -05:00
.gitignore Add 'packages/pretty_logging/' from commit 'd5150f9dee0969e66af0aecae17d0bbdaf2b44cf' 2020-02-15 18:28:16 -05:00
analysis_options.yaml Add 'packages/pretty_logging/' from commit 'd5150f9dee0969e66af0aecae17d0bbdaf2b44cf' 2020-02-15 18:28:16 -05:00
CHANGELOG.md Add 'packages/pretty_logging/' from commit 'd5150f9dee0969e66af0aecae17d0bbdaf2b44cf' 2020-02-15 18:28:16 -05:00
LICENSE Add 'packages/pretty_logging/' from commit 'd5150f9dee0969e66af0aecae17d0bbdaf2b44cf' 2020-02-15 18:28:16 -05:00
pubspec.yaml Add 'packages/pretty_logging/' from commit 'd5150f9dee0969e66af0aecae17d0bbdaf2b44cf' 2020-02-15 18:28:16 -05:00
README.md Add 'packages/pretty_logging/' from commit 'd5150f9dee0969e66af0aecae17d0bbdaf2b44cf' 2020-02-15 18:28:16 -05:00

pretty_logging

Pub

Standalone helper for colorful logging output, using pkg:io AnsiCode.

Installation

In your pubspec.yaml:

dependencies:
  pretty_logging: 1.0.0

Usage

Basic usage is very simple:

myLogger.onRecord.listen(prettyLog);

However, you can conditionally pass logic to omit printing an error, provide colors, or to provide a custom print function:

var pretty = prettyLog(
  logColorChooser: (_) => red,
  printFunction: stderr.writeln,
  omitError: (r) {
    var err = r.error;
    return err is AngelHttpException && err.statusCode != 500;
  },
);
myLogger.onRecord.listen(pretty);