Skip to content

monstar-lab-oss/lib-log-viewer

Repository files navigation

lib-log-viewer (Name under discussion)

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

Future plans

  • Take screenshot together with the log
  • Various log sharing options

Usage

Initialize the logging library

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)

Logging

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 */)

Viewing logs

You can view your logs in the LogViewerActivity:

LogViewerActivity
    .createIntent(context)
    .let { startActivity(it) }

First a category has to be selected.

Log categories screenshot

Then all the logs for that category will be shown.

Log list screenshot

Landscape orientation allows more message text to be seen. Line numbers are also shown then.

Landscape log list screenshot

Tapping on a log opens its details.

Assert log details screenshot Debug log details screenshot

About

A library for storing and analysing logs within a debugged application

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published