|
| 1 | +# ⚡️ BoltLogger! |
| 2 | +_**Super charge your logging and zap logs like Zeus with the BoltLogger.**_ |
| 3 | + |
| 4 | +## 🚀 Features |
| 5 | + - Built on top of the `logging` package. Meaning package that use the `logging` package will also be visible in the BoltLogger. |
| 6 | + - Easy to use and setup. |
| 7 | + - Supports multiple charges (log outputs). |
| 8 | + - Supports multiple log levels. |
| 9 | + - Has extension methods for easy logging, with include reference to the calling class. |
| 10 | + |
| 11 | +## 🛠 Setup |
| 12 | +To use the `BoltLogger`, you need to charge the logger with a `BoltCharge`. |
| 13 | + |
| 14 | +```dart |
| 15 | +BoltLogger.charge(DebugConsoleCharge()); |
| 16 | +``` |
| 17 | + |
| 18 | +Available charges: |
| 19 | + - `DebugConsoleCharge`: Logs output to the console. |
| 20 | + - `FileCharge`: Logs output to a file. |
| 21 | + - `MemoryCharge`: Keeps track of logs in memory. |
| 22 | + |
| 23 | +## 📝 Zapping! (Usage) |
| 24 | +The `BoltLogger` aims to be easy to use. Once `BoltLogger` is charged you can start zapping logs! By zapping we mean literally calling `zap`. |
| 25 | + |
| 26 | +Logging a message in `BoltLogger` is as simple as calling the `zap` method. |
| 27 | + |
| 28 | +```dart |
| 29 | +class MyAwesomeClass{ |
| 30 | + void doSomething() { |
| 31 | + zap('This is a message'); |
| 32 | + } |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +`BoltLogger` offer `zap` as a extension on `Object` meaning you can call `zap` on or in any object. |
| 37 | +Because it's an extension we can automatically include the `runtimeType` of the object that called `zap` as tag for the log message. |
| 38 | + |
| 39 | +Just as Zeus when zapping your not only limited to only zap `String`s, you can zap any object. For example: Exceptions, Errors, StackTrace. BoltLogger will take care of the objects accordingly. |
| 40 | + |
| 41 | +Beside zapping messages you can also provide a custom `tag` and `level` to the `zap` method. |
| 42 | + |
| 43 | +`BoltLogger` also offers a `shock` to zap logs with at a `Level.SERVERE` level. |
| 44 | + |
| 45 | +If the extension methods are not available you can call `BoltLogger.zap` directly. |
| 46 | + |
| 47 | +## 📦 Example |
| 48 | +```dart |
| 49 | +
|
| 50 | +class MyAwesomeClass{ |
| 51 | + void doSomething() { |
| 52 | + zap('This is a message'); |
| 53 | + } |
| 54 | + |
| 55 | + void doSomethingElse() { |
| 56 | + shock(Exception('Shocking!')); |
| 57 | + } |
| 58 | +} |
| 59 | +
|
| 60 | +void main() { |
| 61 | + BoltLogger.charge(DebugConsoleCharge()); |
| 62 | + |
| 63 | + final myAwesomeClass = MyAwesomeClass(); |
| 64 | + myAwesomeClass.doSomething(); |
| 65 | + myAwesomeClass.doSomethingElse(); |
| 66 | +} |
| 67 | +``` |
0 commit comments