A library for storing and analysing logs within a debugged application. You can:
- Group logs into categories (e.g. "API calls", "Database writes", "Calculation results" etc.)
- Attach common severity levels to logs (e.g. "Warning", "Error" etc.) as well as add custom ones
- View logs for a specific category in real time
- View details for each log
- Take screenshot together with the log
- Various log sharing options
You need to initialize the library before logging anything. Usually you'd want to do this in onCreate(...)
of your Application
child class.
Logger.initialize(context)
By default, the logs are stored in a Room-backed database. However, you can create your own implementation of LogRepository
and use that instead.
Logger.initialize(context, myRepository)
Your log entry contains the following information:
- The time of logging (inserted automatically)
- A category name to group your logs under ("General" by default)
- A severity level (e.g. warning, error, debug etc.); verbose by default.
- A tag (optional)
- A throwable (optional)
- A log message
You can store logs with:
Logger.log(
message,
severityLevel,
tag,
categoryName,
throwable
)
Helper extensions are also provided to reflect the more common Android Log
class functions:
Logger.v(/* arguments without the severity level */)
Logger.i(/* arguments without the severity level */)
Logger.d(/* arguments without the severity level */)
Logger.w(/* arguments without the severity level */)
Logger.e(/* arguments without the severity level */)
Logger.wtf(/* arguments without the severity level */)
You can view your logs in the LogViewerActivity
:
LogViewerActivity
.createIntent(context)
.let { startActivity(it) }