gitmyhub

logger

Java ★ 14k updated 3y ago

✔️ Simple, pretty and powerful logger for android

A small Android library that replaces the default Logcat output with visually formatted log messages, borders, thread info, stack traces, pretty-printed JSON and XML, making Android Studio debug logs much easier to read at a glance.

JavaAndroidGradlesetup: easycomplexity 1/5

Logger is a small Java library for Android that makes log output in Android Studio easier to read. When you are building an Android app, developers frequently print messages to a debug console to understand what the app is doing. Android has a built-in logging system called Logcat, but its output can be hard to scan at a glance. Logger formats those same messages with borders, thread information, and method traces so they stand out visually.

Adding it to a project takes two steps: one line in the build file to include the library as a dependency, and one line of Java code to initialize it. After that you call Logger's methods the same way you would call the standard Android log functions, passing a message string. It supports all the standard log levels: debug, error, warning, verbose, information, and a special level the library calls "What a Terrible Failure" for catastrophic errors.

Beyond plain text messages, Logger can also pretty-print JSON and XML content, which formats structured data in an indented, readable way rather than printing it as a single long line. Collections like lists, maps, sets, and arrays are also handled, printing their contents in a structured format instead of showing only the object reference.

The library lets you customize how logs are formatted: you can hide the thread info, control how many levels of the call stack are shown, redirect output to a custom destination, or set a global tag for all messages. A loggable check function makes it easy to disable all log output in production builds with a single flag, so debug messages do not appear for end users.

Logs can also be saved to disk by swapping to a different adapter that writes to a CSV file. There is also an integration option for Timber, another popular Android logging wrapper.

Where it fits