https://github.com/chenenyu/dog
Simple and pretty log package for Dart, includes Flutter and web.
https://github.com/chenenyu/dog
console dart dart-log dart-web dartjs flutter flutter-log log logger print web
Last synced: 4 months ago
JSON representation
Simple and pretty log package for Dart, includes Flutter and web.
- Host: GitHub
- URL: https://github.com/chenenyu/dog
- Owner: chenenyu
- License: apache-2.0
- Created: 2020-11-02T10:15:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-10-20T07:14:10.000Z (over 4 years ago)
- Last Synced: 2023-08-20T21:47:32.511Z (almost 3 years ago)
- Topics: console, dart, dart-log, dart-web, dartjs, flutter, flutter-log, log, logger, print, web
- Language: Dart
- Homepage: https://pub.dev/packages/dog
- Size: 731 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Dog
[](https://pub.dev/packages/dog)
Simple and pretty log package for Dart, includes Flutter and web.
## Getting Started
### Install
```yaml
dependencies:
dog: any # replace 'any' with version number.
```
```dart
import 'package:dog/dog.dart';
```
### Usage
```dart
// simple log
dog.v('verbose');
dog.d('debug');
dog.i('info');
dog.w('warning');
dog.e('error');
```

```dart
// Map.
dog.i({
'a': 1,
'b': {'b1': '2', 'b2': '2'},
'c': 3
});
// Iterable.
dog.w([1, 2, 3, 4, 5]);
// Function.
dog.d(() => 'This this a message returned by Function.');
```

```dart
// Exception/StackTrace
try {
throw Exception('This is an exception.');
} catch (e, st) {
dog.e(e, stackTrace: st);
}
```

```dart
// tag and title support
dog.i({'success': true}, tag: 'HTTP', title: 'Response: https://api.example.com/');
```

Web platform support:

#### Dog level
See [Level](lib/src/level.dart).
```dart
// disable Dog
dog.level = Level.OFF;
```
#### Formatter
[`PrettyFormatter`](lib/src/formatter/pretty_formatter.dart): Convert message to pretty styles.
[`SimpleFormatter`](lib/src/formatter/simple_formatter.dart): Format message without borders.
#### Emitter
[`ConsoleEmitter`](lib/src/emitter/console_formatter.dart): Output message to console.
[`FileEmitter`](lib/src/emitter/file_formatter.dart): Output message to file, it doesn't support web platform.
## Note
If you are running a flutter app by **AndroidStudio** and the console log is not colorful, then try to enable it manually:
```dart
dog = Dog(handler: Handler(formatter: PrettyFormatter(), emitter: ConsoleEmitter(supportsAnsiColor: true)));
```
## Thanks
[logger](https://github.com/orhanobut/logger): Logger for android.