2024-12-15 03:56:05 +00:00
|
|
|
# Belatuk Petty Logging
|
|
|
|
|
|
|
|

|
|
|
|
[](https://dart.dev/null-safety)
|
|
|
|
[](https://gitter.im/angel_dart/discussion)
|
|
|
|
[](https://github.com/dart-backend/belatuk-common-utilities/blob/main/packages/pretty_logging/LICENSE)
|
|
|
|
|
|
|
|
**Replacement of `package:pretty_logging` with breaking changes to support NNBD.**
|
|
|
|
|
|
|
|
Standalone helper for colorful logging output, using pkg:io AnsiCode.
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
In your `pubspec.yaml`:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
dependencies:
|
|
|
|
platform_pretty_logging: ^6.1.0
|
|
|
|
```
|
|
|
|
|
|
|
|
## 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;
|
2024-12-15 10:56:25 +00:00
|
|
|
return err is PlatformHttpException && err.statusCode != 500;
|
2024-12-15 03:56:05 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
myLogger.onRecord.listen(pretty);
|
|
|
|
```
|