Git Product home page Git Product logo

lgr's Introduction

lgr

Lgr is yet another Java Logging Framework

Why another Java Logging Framework?

Because, quite frankly, most logging frameworks are over-engineered and hard to use. Logging should be a "no-brainer" and not yet another tool that requires a couple of hours/days to set up.

Installation

  1. Copy Lgr.java into your project.

Usage

import at.int32.lgr;

Lgr.i("Hello World!");
Lgr.w("This is a warning: %s", "Don't try this at home.");

try {
  throw new IllegalArgumentException("error");
} catch (Exception e) {
  Lgr.e(e, "This is a custom error message: %s", "Quite the failure.");
}

which will produce the following result:

2018-01-12 13:02:51:056 [INFO]	Hello World!
2018-01-12 13:02:51:110 [WARN]	This is a warning: Don't try this at home.
2018-01-12 13:02:51:113 [ERROR]	This is a custom error message: Quite the failure. java.lang.IllegalArgumentException: error
	at at.int32.lgr.App.main(App.java:9)

Loggers

By default Lgr will print to System.out using the integrated Lgr.ConsoleLgrclass.

Following loggers are already contained within Lgr:

  • Lgr.ConsoleLgr
  • Lgr.FileLgr

To write your own custom Lgr simply implemented the Lgr.ILgr interface.

To use a different, multiple, or even custom Loggers simply do the following:

Lgr.set(new ConsoleLgr(), new FileLgr("output.log"), new MyCustomLgr());

Format

To change the desired output format use the static Lgr.FORMAT field. By default it's formated like this:

//Example: 2018-01-12 13:02:51:056 [INFO]	Hello World!
%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS:%1$tL [%2$s]\t%3$s

Example: 2018-01-12 13:02:51:056 [INFO] Hello World!

  • %1 = Date (java.util.Date)
  • %2 = Level (Lgr.Level)
  • %3 = Message (System.String)

lgr's People

Contributors

int32at avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.