Skip to content

Instantly share code, notes, and snippets.

@MFlisar
MFlisar / lumberjack_notification_demo.kt
Created Dec 20, 2021
Lumberjack Notification Demo
View lumberjack_notification_demo.kt
// show a crash notifcation - on notification click the user can send a feedback mail including the log file
L.showCrashNotification(context, logFile /* may be null */, "some.mail@gmail.com", R.mipmap.ic_launcher, "NotificationChannelID", 1234 /* notification id */)
// show a notification to allow the user the report some interesting internal proplems
L.showCrashNotification(context, fileLoggingSetup, "some.mail@gmail.com", R.mipmap.ic_launcher, "NotificationChannelID", 1234 /* notification id */)
// show an information notification to the user (or for dev purposes)
L.showInfoNotification(context, "NotificationChannelID", 1234 /* notification id */, "Notification Title", "Notification Text", R.mipmap.ic_launcher)
// as above, but on notification click it will open the log viewer showing the provided log file
View lumberjack_viewer_demo.kt
// if you provide a mail address, the viewer will add a "send mail" entry to its menu
L.showLog(context, fileLoggingSetup, "some.mail@gmail.com" /* optional */)
View lumberjack_feedback_demo.kt
// send the most recent log file via mail
L.sendFeedback(context, fileLoggingSetup, "some.mail@gmail.com")
View lumberjack_filter_demo.kt
// e.g. completely disable logs in debug
L.enabled = BuildConfig.DEBUG
// e.g. disable all tags that are not starting with "IMPORTANT_"
L.tagNameFilter = { it.startsWith("IMPORTANT_") }
// e.g. disable logs from any non app package name
L.packageNameFilter = { it.startsWith("com.my.package.name") }
@MFlisar
MFlisar / lumberjack_log.txt
Last active Dec 20, 2021
Lumberjack - Log Example
View lumberjack_log.txt
[MainActivity:2 onCreate]: This is my first log entry (MainActivity.kt:2)
[MainActivity:3 onCreate]: This is my second log entry - it will be logged because logIf evaluates to true (MainActivity.kt:3)
[MainActivity:5 onCreate]: Log line 3 will not slow down this code because the function inside the log will never be called because the logIf evaluates to false (MainActivity.kt:5)
[<TAG1> MainActivity:8 onCreate]: Log with tag (MainActivity.kt:8)
View lumberjack_demo.kt
// simple logs
L.d { "This is my first log entry" }
L.logIf { true }?.d { "This is my second log entry - it will be logged because logIf evaluates to true" }
L.logIf { false }?.d { "Slow log line without any impact at runtime - sleeping 5s: ${ Thread.sleep(5000) }"}
L.d { "Log line 3 will not slow down this code because the function inside the log will never be called because the logIf evaluates to false" }
// optionally tag a log line - tags are useful to group logs and can be disabled at runtime
L.tag("TAG1").d { "Log with tag" }
@MFlisar
MFlisar / lumberjack_setup.kt
Last active Dec 20, 2021
Lumberjack - Setup Example
View lumberjack_setup.kt
// 1) plant the console logging tree
L.plant(ConsoleTree())
// 2) plant a file logging tree
val setup = FileLoggingSetup.Setup(logsToKeep = 1, fileExtension = "txt")
val fileLoggingSetup = FileLoggingSetup.DateFiles(context, setup)
// alternatively use number file names instead of date based file names if desired
// val fileLoggingSetup = FileLoggingSetup.NumberedFiles(context, setup)
L.plant(FileLoggingTree(fileLoggingSetup))
@MFlisar
MFlisar / build.gradle
Created Oct 25, 2018
Example Project build.gradle
View build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: './versions.gradle'
buildscript {
repositories {
// ...
}
dependencies {
classpath 'com.android.tools.build:gradle:' + versions.gradlePlugin
View MyViewGroupMviDelegateImpl.java
package com.appindustry.everywherelauncher.mvi;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.View;
View InstantTarget.java
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.bumptech.glide.request.target.BaseTarget;
import com.bumptech.glide.request.target.SizeReadyCallback;
import com.bumptech.glide.request.transition.Transition;
public class InstantTarget extends BaseTarget<Drawable> {
private Drawable drawable;