Logger

The small library for logging which supports different priorities and strategies.

License

License

GroupId

GroupId

com.github.nikolaymenzhulin
ArtifactId

ArtifactId

logger
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

aar
Description

Description

Logger
The small library for logging which supports different priorities and strategies.
Project URL

Project URL

https://github.com/NikolayMenzhulin/Logger
Source Code Management

Source Code Management

https://github.com/NikolayMenzhulin/Logger

Download logger

How to add to project

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

Dependencies

compile (1)

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

runtime (1)

Group / Artifact Type Version
com.jakewharton.timber : timber jar 4.7.1

Project Modules

There are no modules declared in this project.

Logger

The small library for logging which supports different priorities and strategies.

build Maven Central License

Usage

Logger works with strategies that must be extends from LoggerStrategy interface. The library already provides the two realisations: TimberLoggerStrategy based on Timber and TestLoggerStrategy orientired on using in tests. In addition to these, you can implement your own. By default Logger uses TimberLoggerStrategy.

Use the following example of code to add strategies:

Logger.strategies.add(TimberLoggerStrategy())

// or

val strategies = listOf(TimberLoggerStrategy(), SomeOtherLoggerStrategy())
Logger.strategies.addAll(strategies)

Logger.strategies is actually a MutableList, so when you working with it you can use all the same methods the regular MutableList has.

The code for adding strategies is better placed in the application class of your app.
When you try using Logger without strategies it will be throw IllegalStateException.

After adding strategies use the following example of code to log something what you need:

// Logging uses TimberLoggerStrategy.

Logger.d("Hello world!") // Print "Hello World!" to DEBUG channel of Logcat.

Logger.e(Exception("Error message")) // Print the exception with the message "Error message" and the stacktrace to ERROR channel of Logcat.

Logger.i("Info with args: arg1=%s, arg2=%s", 1, 2) // Print "Info with args: arg1=1, arg2=2" to INFO channel of Logcat.

// etc.

Download

Step 1. Add the Maven Central repository to your build file:

allprojects {
    repositories {
        mavenCentral()
    }
}

Step 2. Add the dependency:

dependencies {
    implementation 'com.github.nikolaymenzhulin:logger:1.1.1'
}

License

Copyright © 2021 Nikolay Menzhulin.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
1.1.1
1.1.0
1.0.0