2021-06-21 15:04:36 +00:00
|
|
|
# Angel3 Petty Logging
|
|
|
|
|
2021-05-15 05:44:31 +00:00
|
|
|
[![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
|
|
|
|
2021-09-25 07:18:01 +00:00
|
|
|
**DEPRECATED: Replaced by [`belatuk_pretty_logging`](https://pub.dartlang.org/packages/belatuk_pretty_logging) package**
|
|
|
|
|
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
|
|
|
|
2021-06-21 15:04:36 +00:00
|
|
|
## Installation
|
|
|
|
|
2019-08-09 22:53:32 +00:00
|
|
|
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
|
|
|
```
|
|
|
|
|
2021-06-21 15:04:36 +00:00
|
|
|
## Usage
|
|
|
|
|
2019-08-09 22:53:32 +00:00
|
|
|
Basic usage is very simple:
|
|
|
|
|
|
|
|
```dart
|
|
|
|
myLogger.onRecord.listen(prettyLog);
|
|
|
|
```
|
|
|
|
|
2021-06-21 15:04:36 +00:00
|
|
|
However, you can conditionally pass logic to omit printing an error, provide colors, or to provide a custom print function:
|
2019-08-09 22:53:32 +00:00
|
|
|
|
|
|
|
```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);
|
|
|
|
```
|