android-slf4j-logger

Simple implementation of SLF4J Logger for Android

License

License

Categories

Categories

SLF4J Application Layer Libs Logging
GroupId

GroupId

com.github.omarmiatello.android-slf4j-logger
ArtifactId

ArtifactId

core
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

aar
Description

Description

android-slf4j-logger
Simple implementation of SLF4J Logger for Android
Project URL

Project URL

https://github.com/omarmiatello/android-slf4j-logger/
Source Code Management

Source Code Management

https://github.com/omarmiatello/android-slf4j-logger/

Download core

How to add to project

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

Dependencies

compile (1)

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

runtime (1)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.2.3

Project Modules

There are no modules declared in this project.

SLF4J Logger for Android

GitHub license

Simple implementation of SLF4J Logger for Android

Note: Could be used with Ktor

Setup

Add this in your build.gradle.ktx file:

implementation("com.github.omarmiatello.android-slf4j-logger:core:1.0.0")

How to use

The easy way:

logger = AndroidLogger(levelMin = Log.VERBOSE)

The custom way, extend BasicAndroidLogger, as example AndroidLogger

abstract class BasicAndroidLogger(/* ... */) : org.slf4j.helpers.MarkerIgnoringBase() {
    // ...
}

class AndroidLogger(
    levelMin: Int = Log.DEBUG,
    private val tag: String = AndroidLogger::class.java.simpleName,
) : BasicAndroidLogger(levelMin) {

    override fun logV(msg: String, tr: Throwable?) {
        Log.v(tag, msg, tr)
    }

    override fun logD(msg: String, tr: Throwable?) {
        Log.d(tag, msg, tr)
    }

    override fun logI(msg: String, tr: Throwable?) {
        Log.i(tag, msg, tr)
    }

    override fun logW(msg: String, tr: Throwable?) {
        Log.w(tag, msg, tr)
    }

    override fun logE(msg: String, tr: Throwable?) {
        Log.e(tag, msg, tr)
    }
}

License

MIT License

Copyright (c) 2021 Omar Miatello

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Versions

Version
1.0.0