Git Product home page Git Product logo

klogger's Introduction

klogger

What is klogger?

klogger is a erlang app to create loggers with console and file backend. Klogger can create more than one logger with diferents backends and log levels.

Author

This is an openshine project developed by:

  • Pablo Vieytes

Usage

start the application

klogger:start().

Klogger is multi logger application, but no logger is started by default, so, at least one should be added to start to log. You can add as many as you want to. If no options are given when a logger is added, it will have console backend and the higher log level (every message will be showed).

klogger:add_logger(logger).
logger:debug("text message").

The logger name ('logger' in this case) must be an atom. You should be careful with this name. Some code will be compiled dynamically and loaded as logger name.

Options could be a backend tuple or a list of backend tuples Options for console backend:

{backend, [backend_option()]}

backend_option() = name() | type() | loglevel() | level() | path() | get_error_logger()
name() = {name, Name::atom()}
type() = {type, file_backend | console_backend}
loglevel() = {loglevel, integer() | debug | info | warning | error | fatal | none}
path() = {path, Path::string()}
get_error_logger() =  {get_error_logger, enable | disable}

type() and name() are mandatory, and path() is also mandatory for file_backend loggers.

There are defined some integer macros:

  • ?DEBUG
  • ?INFO
  • ?WARNING
  • ?ERROR
  • ?FATAL
  • ?NONE

Add new logger with options:

Options = [
 	{backend, [{name, console_log}, 
			   {type, console_backend},
			   {loglevel, debug},
			   {get_error_logger, enable}
			  ]},
		{backend,  [{name, file_log}, 
			    {type, file_backend},
			    {loglevel, debug},
			    {path, LogFilePath},
			    {get_error_logger, enable}
			   ]}
	       ]
klogger:add_logger(logger, Options).

Log level can be change at runtime.

klogger:set_log_level(logger, {file_log, ?DEBUG}).

License

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.

TODO

  • Erlang error logger integration

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.