Simple Logger for Java and Android

General

Category
Free
Tag
Logging
License
Creative Commons 4.0 BY
Min SDK
21 (Android 5.0–5.0.2 Lollipop)
Registered
Jan 18, 2024
Favorites
0
Link
https://github.com/DIG-/java-logger
See also
Birch
xLog
Galgo
Frodo
Call logs

Additional

Language
Java
Version
1.3.0 (Mar 24, 2023)
Created
Apr 5, 2022
Updated
Mar 24, 2023 (Retired)
Owner
DIG (DIG-)
Contributor
DIG (DIG-)
1
Activity
Badge
Generate
Download
Source code

Simple Logger for Java and Android

  • Make log process easier
  • Logs with scope (and tag)
  • Reduced boilerplate
  • Purely written in Java
  • Integrate with others Log system

Reason

As an Android developer, Timber does not have restricted scope.

How to use

  1. Include maven central as repository
  2. Choose, at least, one logger printer (br.dev.dig.logger.printer) and import into your project.

Simple log for Android:

dependencies {
    ⋮
    implementation "br.dev.dig.logger.printer:android-log:${lastest_version}"
    ⋮
}
  1. Create your own LoggerBuilder (can be a singleton)
object MainLoggerBuilder : LoggerBuilder() {
    override fun getBaseLogger(): BaseLogger {
        return AndroidLogLogger()
    }
}
  1. Get Logger instance:
val log = MainLoggerBuilder.logger
// OR
val log = Logger.getInstance(MainLoggerBuilder)

// With tag:
val log = MainLogger.getLogger("tag")
// OR
val log = Logger.getInstance(MainLoggerBuilder, "tag")

Logger Printers

Can be found in folder printer or doing some maven search for group br.dev.dig.logger.printer.

Package Class Description
stub StubLogger Do nothing.
println PrintLnLogger Use println as output. Format can be customized.
stream StreamLogger Use OutputStream as output. Format can be customized.
system-log SystemLogLogger Use platform native log system
--------------- ----------------------- -------------
android-log AndroidLogLogger Use Android native Log as output.
firebase FirebaseLogger Use Firebase Crashlytics as output (non-fatal).
timber TimberLogger Use Timber as output.

Utilities

Some utilities that can help or improve Log operations. All of them are under group br.dev.dig.logger (search).

Utilities are chainable. Comparing to tree structure, Printers are leafs and Utilities are branch.

Package Class Description
async AsyncLogger Propagate log in other Executor
filter FilterLogger Propagate log with level above desired level
union UnionLogger Propagate log to more than one BaseLogger

Kotlin extension

All package has its own kotlin extension, some are just alias, but if have builder, will have extension.

License

CC BY-ND 4.0

  • You can use and re-dist freely.
  • You can also modify, but only for yourself.
  • You can use it as a part of your project, but without modifications in this project.