Skip to content

Instantly share code, notes, and snippets.

@MFlisar
MFlisar / lumberjack_notification_demo.kt
Created December 20, 2021 08:33
Lumberjack Notification Demo
// 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
@MFlisar
MFlisar / lumberjack_viewer_demo.kt
Created December 20, 2021 08:23
Lumberjack Viewer Demo
// 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 */)
@MFlisar
MFlisar / lumberjack_feedback_demo.kt
Created December 20, 2021 08:20
Lumberjack Feedback
// send the most recent log file via mail
L.sendFeedback(context, fileLoggingSetup, "some.mail@gmail.com")
@MFlisar
MFlisar / lumberjack_filter_demo.kt
Created December 20, 2021 08:16
Lumberjack - Filtering
// 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 December 20, 2021 08:07
Lumberjack - Log Example
[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)
// 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 December 20, 2021 08:08
Lumberjack - Setup Example
// 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 October 25, 2018 06:35
Example Project 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
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;
@MFlisar
MFlisar / InstantTarget.java
Created February 7, 2018 06:37
InstantTarget
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;