Logging Adapters for Java

Adapters for various Java and Android logging implementations

Лицензия

Лицензия

Категории

Категории

Java Языки программирования Logging Библиотеки уровня приложения
Группа

Группа

com.cookingfox
Идентификатор

Идентификатор

logging-adapter-java
Последняя версия

Последняя версия

0.4.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Logging Adapters for Java
Adapters for various Java and Android logging implementations
Ссылка на сайт

Ссылка на сайт

http://github.com/cookingfox/logging-adapter-java
Организация-разработчик

Организация-разработчик

Cooking Fox
Система контроля версий

Система контроля версий

http://github.com/cookingfox/logging-adapter-java

Скачать logging-adapter-java

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.cookingfox/logging-adapter-java/ -->
<dependency>
    <groupId>com.cookingfox</groupId>
    <artifactId>logging-adapter-java</artifactId>
    <version>0.4.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.cookingfox/logging-adapter-java/
implementation 'com.cookingfox:logging-adapter-java:0.4.0'
// https://jarcasting.com/artifacts/com.cookingfox/logging-adapter-java/
implementation ("com.cookingfox:logging-adapter-java:0.4.0")
'com.cookingfox:logging-adapter-java:jar:0.4.0'
<dependency org="com.cookingfox" name="logging-adapter-java" rev="0.4.0">
  <artifact name="logging-adapter-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.cookingfox', module='logging-adapter-java', version='0.4.0')
)
libraryDependencies += "com.cookingfox" % "logging-adapter-java" % "0.4.0"
[com.cookingfox/logging-adapter-java "0.4.0"]

Зависимости

provided (2)

Идентификатор библиотеки Тип Версия
org.slf4j : slf4j-api jar 1.7.12
com.google.android : android jar 4.1.1.4

test (4)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.hamcrest : hamcrest-core jar 1.3
com.jcabi : jcabi-matchers jar 1.3
ch.qos.logback : logback-classic jar 1.1.3

Модули Проекта

Данный проект не имеет модулей.

Logging Adapters for Java

Adapters for various Java and Android logging implementations.

Build Status

Features

  • Contains adapters for popular logging libraries. (i.e. Android Log, SLF4J)
  • Easy to implement your own adapter through a simple interface.
  • Simple log method calls: no need to define a TAG (Android) or create a logger per class (SLF4J).

Download

Download Maven Central

The distribution is hosted on Bintray. To include the package in your projects, you can add the jCenter repository.

Gradle

Add jCenter to your repositories block:

repositories {
    jcenter()
}

and add the project to the dependencies block in your build.gradle:

dependencies {
    compile 'com.cookingfox:logging-adapter-java:0.4.0'
}

Maven

Add jCenter to your repositories in pom.xml or settings.xml:

<repositories>
    <repository>
        <id>jcenter</id>
        <url>http://jcenter.bintray.com</url>
    </repository>
</repositories>

and add the project declaration to your pom.xml:

<dependency>
    <groupId>com.cookingfox</groupId>
    <artifactId>logging-adapter-java</artifactId>
    <version>0.4.0</version>
</dependency>

Usage

Example using Android adapter:

Logger.init().setLoggerAdapter(new AndroidLoggerAdapter());

Logger.debug("Created a user: %s", user);

Configuration

The following example is used to explain the configuration options:

package com.example;

import com.cookingfox.logging.Logger;

public class MyClass {
   public void myMethod() {
       Logger.debug("Hello!");
   }
}

When one of the Logger methods is called, a reference to the 'caller' is generated by analyzing the stack trace. By default, the way this caller reference is formatted is its fully-qualified class name. For the above example, this would be: com.example.MyClass.

To configure the Logger, you call Logger.init(), which returns a Settings object. This class provides the following options:

setLoggerAdapter()

Sets the LoggerAdapter instance, which typically wraps a third party logging library. Of course, you can always create your own implementation. It is not possible to set multiple logger adapters.

setEnabled()

Use this method to enable or disable logging. For example, you can disable logging for your release build.

callerAddLineNumber()

Set to true to add the caller line number, for example: com.example.MyClass:7.

callerAddMethodName()

Set to true to add the caller method name, for example: com.example.MyClass#myMethod.

callerUseSimpleName()

Set to true to use a simple class name for the caller, for example: MyClass.

Example output when all caller options are set to 'true'

MyClass#myMethod:7

Версии библиотеки

Версия
0.4.0
0.3.2
0.3.1
0.3.0
0.2.2
0.1.2