2021-05-15 05:44:31 +00:00
|
|
|
# angel3_pretty_logging
|
|
|
|
[![version](https://img.shields.io/badge/pub-v3.0.3-brightgreen)](https://pub.dartlang.org/packages/angel3_pretty_logging)
|
2021-05-14 03:49:34 +00:00
|
|
|
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
2021-05-15 03:52:28 +00:00
|
|
|
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
|
2021-05-14 03:49:34 +00:00
|
|
|
|
2021-05-14 10:34:09 +00:00
|
|
|
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/pretty_logging/LICENSE)
|
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);
|
|
|
|
```
|