Skip to content

notz/android-logging-helper

Repository files navigation

Android logging helper

Helper functions to make java logging funny on Android

Supports logcat, file logging with memory buffer, sharing zipped log file and install uncaught exception handler.

The lib uses native java logging and is very small.

Usage

Add the content provider to your application manifest

<provider
	android:name="at.pansy.android.logging.helper.LogFileProvider"
	android:authorities="${applicationId}.logfileprovider"
	android:enabled="true"
	android:exported="false"
	android:grantUriPermissions="true" />

Initialize logging in your application class

public class DemoApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        LoggingHelper.configure(this, "logging-demo", true, Level.FINE);
        LoggingHelper.setupUncaughtExceptionHandler();
    }

    @Override
    public void onTerminate() {
        LoggingHelper.flush();
        super.onTerminate();
    }
}

In your application use java logging

logger.config("This is a debug log entry");
logger.info("This is a info log entry");
logger.warning("This is a warning");
logger.severe("This is a error");

try {
    throw new RuntimeException("This is a runtime exception");
} catch (Exception e) {
    logger.log(Level.SEVERE, e.getMessage(), e);
}

logger.log(Level.WARNING, "this is a formatted {0}", new Object[] { "message"});

It's easy to share your log

LoggingHelper.shareLog(MainActivity.this, "[email protected]", "This is a logging demo");

About

Helper functions to make java logging funny on Android

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors 3

  •  
  •  
  •  

Languages