Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
MFlisar committed Oct 28, 2020
1 parent 3b50a9e commit 8fd1371
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ A simple logger for JackWhartons [Timber](https://github.com/JakeWharton/timber)
* 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`
* feedback module that contains extension functions for `L` to send feedback or to show a notification that will send a feedback on click:
* L.sendFeedback()... sends a feedback via IntentChooser with an optional files appended
* L.showCrashNotification()... shows a notification which will send a feedback if clicked
* `L.sendFeedback()`... sends a feedback via IntentChooser with an optional files appended
* `L.showCrashNotification()`... shows a notification which will send a feedback if clicked

**All features are splitted into separate modules, just include the modules you want to use!**

Expand Down Expand Up @@ -51,13 +51,33 @@ Once in your app do following:
```kotlin
// simply console logger
L.plant(ConsoleTree())
// a file logger (optional)
val fileLoggingSetup = FileLoggingSetup.DateFiles(context) // default setup keeps log files for 7 days and creates a new file each day
L.plant(FileLoggingTree(fileLoggingSetup))
// if desired, disable all logging in release
// L.enabled = Build.DEBUG
```

With the `filelogger` module you need to do following:

```kotlin
// a file logger (optional)
// here you can setup a date file or a number file file logger - all variables like folder, filename, extension, file to keep and so on can be customised
// when creating the setup
// following default setup keeps log files for 7 days and creates a new file each day and names them "log_YYYYmmdd.log" by default
val fileLoggingSetup = FileLoggingSetup.DateFiles(context)
L.plant(FileLoggingTree(fileLoggingSetup))
```

With the `feedback` module you can also do following:

```kotlin
// send feedback with the log file appended (chooser to select a mail will be opened, no internet permission needed!)
L.sendFeedback(context, fileLoggingSetup, "[email protected]")

// show a notification to allow the user the report some interesting internal proplems
L.showCrashNotification(context, fileLoggingSetup, "[email protected]", R.mipmap.ic_launcher, "NotificationChannelID", 1234 /* notification id */)
```

Check out the demo to see more

### Example - LOGGING

The logger is simply used like following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ fun L.sendFeedback(
fun L.showCrashNotification(
context: Context,
fileLoggingSetup: FileLoggingSetup,
appendLogFile: Boolean,
receiver: String,
appIcon: Int,
notificationChannelId: String,
notificationId: Int,
notificationTitle: String = "Rare exception found",
notificationText: String = "Please report this error by clicking this notification, thanks",
subject: String = "Exception found in ${context.packageName}",
appendLogFile: Boolean = true,
titleForChooser: String = "Send report with",
filesToAppend: List<File> = emptyList()
) {
Expand Down

0 comments on commit 8fd1371

Please sign in to comment.