Logging Library

Logging Library for Android

License

License

GroupId

GroupId

dev.assemblage
ArtifactId

ArtifactId

logger-lib
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

aar
Description

Description

Logging Library
Logging Library for Android
Project URL

Project URL

https://github.com/umang91/SmartLogger
Source Code Management

Source Code Management

https://github.com/umang91/SmartLogger

Download logger-lib

How to add to project

<!-- https://jarcasting.com/artifacts/dev.assemblage/logger-lib/ -->
<dependency>
    <groupId>dev.assemblage</groupId>
    <artifactId>logger-lib</artifactId>
    <version>2.0.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/dev.assemblage/logger-lib/
implementation 'dev.assemblage:logger-lib:2.0.0'
// https://jarcasting.com/artifacts/dev.assemblage/logger-lib/
implementation ("dev.assemblage:logger-lib:2.0.0")
'dev.assemblage:logger-lib:aar:2.0.0'
<dependency org="dev.assemblage" name="logger-lib" rev="2.0.0">
  <artifact name="logger-lib" type="aar" />
</dependency>
@Grapes(
@Grab(group='dev.assemblage', module='logger-lib', version='2.0.0')
)
libraryDependencies += "dev.assemblage" % "logger-lib" % "2.0.0"
[dev.assemblage/logger-lib "2.0.0"]

Dependencies

runtime (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.4.31

Project Modules

There are no modules declared in this project.

SmartLogger

Small utility library for for logging. This is just because was lazy to copy the same file in every project.

MavenBadge

Features:

  • Consistent log tag for all logs.
  • Enable specific log level.
  • Classname of the method included by defualt.
  • Need not bother about disabling logs for signed build.

Usage

Installation

To use the logger library add the below dependency in the app level build.gradle

implementation("dev.assemblage:logger-lib:$sdkVersion")

replace $sdkVersion with the latest SDK version.

Initialize Logger

Before you start using the SmartLogger it needs to initialized. This is requried because SmartLogger prints logs only if the application is in debug mode, if it is a signed build the SmartLogger does not print any logs. Though logs can be enabled for signed build as well, described later. To initialize the logger add the below line of code in the application class.

  SmartLogHelper.initializeLogger(applicationContext)

Set log level

With SmartLogger one can enable logs based on the log levels. This eases readability of the logs and you only see the kind of logs you want to see. By default the log level is set to Info and can be changed by setting the log level in the application class.

  SmartLogHelper.LOG_LEVEL = SmartLogHelper.LOG_LEVEL_VERBOSE

Set log tag

Setting a specific log tag for all the logs helps in filtering the logs of your application/SDK. By default the tag is set to SmartLogger. You can set the tag based on your application/SDK name.Below is an example on how to set the log tag. The tag needs to be set in the application class.

  SmartLogHelper.LOG_TAG = "SampleApplication"

Enable log for signed builds
By default logs are disabled for signed builds. In case you want to enable logs for signed builds you can do so by adding the below code in the application class

  SmartLogHelper.LOG_STATUS = true

Adding log to your class

class MainActivity : AppCompatActivity(),SmartLogger {

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    info("info log")
    error("error log")
    warn("warning log")
    debug("debug log")
    verbose("verbose log")
  }
}

Refer to the API documentation for more details.

Versions

Version
2.0.0