Skip to content

Commit

Permalink
cleaned code, updated versions, added L.packageNameFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
MFlisar committed Oct 21, 2020
1 parent 4742f95 commit 844ac7f
Show file tree
Hide file tree
Showing 40 changed files with 99 additions and 2,948 deletions.
43 changes: 14 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

### What does it do?

![Demo](https://github.com/MFlisar/Lumberjack/blob/master/files/demo.gif?raw=true)

A simple logger for JackWhartons [Timber](https://github.com/JakeWharton/timber) logging library with following *features*:

* trees for:
* logging to console (with the ability to add clickable links to the calling line in the calling class)
* files (one file per day, select between numbered log file names or date based log file names)
* customise each tree to whatever you want or extend them or add your own tree
* little utility class to log time and laps
* little utility class to log time and laps (the `T` class)
* by default, this library will create tags if no custom tag is provided like "[CLASSNAME:LINE] FUNCTION" e.g. `[MainActivity:32 onCreate]: Some log`

**All features are splitted into separate modules, just include the modules you want to use!**
Expand All @@ -19,23 +17,23 @@ A simple logger for JackWhartons [Timber](https://github.com/JakeWharton/timber)

1) add jitpack to your project's `build.gradle`:

```groovy
```
repositories {
maven { url "https://jitpack.io" }
}
```

2) add the compile statement to your module's `build.gradle`:

```groovy
```
dependencies {
// base module (NECESSARY)
compile 'com.github.MFlisar.Lumberjack:lumberjack-library:<LATEST-VERSION>'
implementation 'com.github.MFlisar.Lumberjack:lumberjack-library:<LATEST-VERSION>'
// modules (OPTIONAL)
compile 'com.github.MFlisar.Lumberjack:lumberjack-filelogger:<LATEST-VERSION>'
implementation 'com.github.MFlisar.Lumberjack:lumberjack-filelogger:<LATEST-VERSION>'
// ALTERNATIVELY you can add ALL modules at once like following
// compile 'com.github.MFlisar:Lumberjack:<LATEST-VERSION>'
// implementation 'com.github.MFlisar:Lumberjack:<LATEST-VERSION>'
}
```

Expand All @@ -53,20 +51,14 @@ L.logIf { true }.d { "Is logged, as flag is true" }
L.logIf { someFunction() }.d { "Is logged and only executed if someFunction returns true" }
```

### Example - OUTPUT

This is what the demo setup will print out (to your file, to the notification, to console, to the overlay). It has pretty printing enabled and prints first 5 values of an array automatically. It as well prints caller class and group combined as tag. The demo shows that

* arrays are printed automatically
* custom classes are automatically formatted with the custom formatter you have registered, no matter if the classes are printed inside an array or as a simple value
* caller class, tags and groups are printed
If used with `logIf` the expression is only executed if `logIf` returns true so it's save to keep all the logging lines in production code.

*Example log*
### Example - OUTPUT

```
[MainActivity:26 onCreate]: 1 - Main activity created (MainActivity.kt:26)
[MainActivity:27 onCreate]: 2 - Test message - count: 0 (MainActivity.kt:27)
[MainActivity:28 onCreate]: 3 - Test error (MainActivity.kt:28)
[MainActivity:26 onCreate]: Main activity created (MainActivity.kt:26)
[MainActivity:27 onCreate]: Test message - count: 0 (MainActivity.kt:27)
[MainActivity:28 onCreate]: Test error (MainActivity.kt:28)
java.lang.Throwable: ERROR
at com.michaelflisar.lumberjack.demo.MainActivity.onCreate(MainActivity.kt:28)
at android.app.Activity.performCreate(Activity.java:7183)
Expand All @@ -81,9 +73,6 @@ This is what the demo setup will print out (to your file, to the notification, t
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
[<CUSTOM-TAG> MainActivity:29 onCreate]: 4 - Test message with custom tag (MainActivity.kt:29)
[MainActivity:32 onCreate]: 5 - Test log based on boolen flag (MainActivity.kt:32)
[MainActivity$onCreate:50 run]: 8 - Timer data: Started: true | Laps: 1 | Total = 1501ms | Running: false (MainActivity.kt:50)
```

### Usage
Expand All @@ -96,10 +85,6 @@ L.plant(ConsoleTree())
// a file logger
val fileLoggingSetup = FileLoggingSetup(context) // default setup keeps log files for 7 days and creates a new file each day
L.plant(FileLoggingTree(fileLoggingSetup))
```

### Credits

The overlay logger is based on Hannes Dorfmann's DebugOverlay: https://github.com/sockeqwe/debugoverlay

The idea for kotlin inline functions is based on https://github.com/ajalt/timberkt
// if desired, disable all logging in release
// L.enabled = Build.DEBUG
```
45 changes: 0 additions & 45 deletions demo/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion demo/app/.gitignore

This file was deleted.

32 changes: 0 additions & 32 deletions demo/app/build.gradle

This file was deleted.

17 changes: 0 additions & 17 deletions demo/app/proguard-rules.pro

This file was deleted.

21 changes: 0 additions & 21 deletions demo/app/src/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 844ac7f

Please sign in to comment.