Log

Maven parent project for OSS publishment

License

License

GroupId

GroupId

com.sdklite
ArtifactId

ArtifactId

log
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Log
Maven parent project for OSS publishment
Project URL

Project URL

http://log.sdklite.com
Project Organization

Project Organization

SDKLite
Source Code Management

Source Code Management

https://github.com/sdklite/log

Download log

How to add to project

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

Dependencies

provided (1)

Group / Artifact Type Version
com.google.android : android jar 4.1.1.4

test (6)

Group / Artifact Type Version
junit : junit jar 4.12
org.robolectric : robolectric jar 3.0
org.robolectric : android-all jar 5.0.0_r2-robolectric-1
org.hamcrest : hamcrest-library jar 1.3
org.eclipse.jetty : jetty-server jar 9.3.0.M0
org.eclipse.jetty : jetty-servlet jar 9.3.0.M0

Project Modules

There are no modules declared in this project.

Overview

The log framework is used for message logging, and designed for Android platform in special, there were many famous logging library, such as log4j, slf4j, logback, etc. All of those were designed for Java, but Android is not Java, the cost of time during application startup is a very import evaluation indicator for an application. Reducing the I/O consuming time during application startup is helpful for improving the performance, so, that's why it's been created.

This log framework is an interface for logging, it doesn't contains implementations in default, it must be combined with only one of logger implementations in following list or other implementation.

Getting Started

Logger logger = LoggerFactory.getLogger("Anonymous");

logger.info("Application startup at {0,time} on {0,date}", new Date());

try {
    ...
} catch (Throwable t) {
    logger.error("Oops! error occurred: {0}", t);
}

Customization

The interface and implementaion of logger are bound by the LoggerBinder stub class, so, any logger implementation must implements the stub methods in LoggerBinder class, for example:

LoggerBinder

package com.sdklite.log.bind;

import com.sdklite.log.Level;
import com.sdklite.log.Logger;

public class LoggerBinder {

    public static final LoggerBinder getInstance() {
        return Internal.BINDER;
    }

    private LoggerBinder() {
    }

    public Logger getLogger(final String name) {
        return new ConsoleLogger(name);
    }

    public Level getDefaultLevel() {
        return Level.INFO;
    }

    private staitc final class Internal {
        private static final LoggerBinder BINDER = new LoggerBinder();
    }
}

ConsoleLogger

public class ConsoleLogger extends AbstractLogger {

    private final String name;

    public ConsoleLogger(final String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public Logger println(final Level level, final String msg, final Object... args) {
        if (level.intValue() < Level.ERROR.intValue()) {
            System.out.println(format(msg, args));
        } else if (level.intValue() < Level.OFF.intValue()) {
            System.err.println(format(msg, args));
        }

        return this;
    }

}

Download

GitHub

Download latest source code from here.

Maven

<dependency>
  <groupId>com.sdklite</groupId>
  <groupId>log</groupId>
  <version>0.0.1</version>
</dependency>

Gradle

compile 'com.sdklite:log:0.0.1'

Documentation

Please see http://log.sdklite.com.

com.sdklite

SDKLite

SDKLite

Versions

Version
0.0.1