platform/packages/pretty_logging/README.md

38 lines
1,011 B
Markdown
Raw Normal View History

2019-08-09 22:53:32 +00:00
# pretty\_logging
2021-05-14 03:49:34 +00:00
[![version](https://img.shields.io/badge/pub-v2.12.4-brightgreen)](https://pub.dartlang.org/packages/angel3_pretty_logging)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/pretty_logging)
2019-08-09 22:54:05 +00:00
2019-08-09 22:39:53 +00:00
Standalone helper for colorful logging output, using pkg:io AnsiCode.
2019-08-09 22:53:32 +00:00
# Installation
In your `pubspec.yaml`:
```yaml
dependencies:
2021-05-14 03:49:34 +00:00
angel3_pretty_logging: ^3.0.0
2019-08-09 22:53:32 +00:00
```
# Usage
Basic usage is very simple:
```dart
myLogger.onRecord.listen(prettyLog);
```
However, you can conditionally pass logic to omit printing an
error, provide colors, or to provide a custom print function:
```dart
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);
```