All Projects → eltex-ecss → chronica

eltex-ecss / chronica

Licence: other
Logger framework for Erlang applications

Programming Languages

erlang
1774 projects

Projects that are alternatives of or similar to chronica

clue
a extremely high performance log library for android. 高性能的Android日志库
Stars: ✭ 27 (-52.63%)
Mutual labels:  logger, logging-library
use-reducer-logger
A very basic logger for the useReducer function in the React Hooks API.
Stars: ✭ 89 (+56.14%)
Mutual labels:  logger, logging-library
noodlog
🍜 Parametrized JSON logging library in Golang which lets you obfuscate sensitive data and marshal any kind of content.
Stars: ✭ 42 (-26.32%)
Mutual labels:  logger, logging-library
BLogger
An easy to use modern C++14/17 async cross-platform logger which supports custom formatting/patterns, colored output, Unicode, file logging, log rotation & more!
Stars: ✭ 23 (-59.65%)
Mutual labels:  logger, logging-library
ratlog.js
🐀 Ratlog JavaScript library - Application Logging for Rats, Humans and Machines
Stars: ✭ 24 (-57.89%)
Mutual labels:  logger, logging-library
JJSwiftLog
Swift log library for all platform
Stars: ✭ 51 (-10.53%)
Mutual labels:  logger, logging-library
Flogs
An Advanced Logging Framework develop in flutter that provides quick & simple logging solution.
Stars: ✭ 158 (+177.19%)
Mutual labels:  logger, logging-library
Izumi
Productivity-oriented collection of lightweight fancy stuff for Scala toolchain
Stars: ✭ 423 (+642.11%)
Mutual labels:  logger, logging-library
Simple-Log
dnkpp.github.io/Simple-Log/
Stars: ✭ 13 (-77.19%)
Mutual labels:  logger, logging-library
beautiful logger
Yet another logger API in Java with beautiful features
Stars: ✭ 60 (+5.26%)
Mutual labels:  logger, logging-library
LogDNA-Android-Client
Android client for LogDNA
Stars: ✭ 22 (-61.4%)
Mutual labels:  logger, logging-library
Loggaby
📝 A simple, lightweight and customizable logger.
Stars: ✭ 20 (-64.91%)
Mutual labels:  logger, logging-library
Timber Elixir
🌲 Great Elixir logging made easy
Stars: ✭ 226 (+296.49%)
Mutual labels:  logger, logging-library
RxLogs
An Android & Kotlin Reactive Advanced Logging Framework.
Stars: ✭ 12 (-78.95%)
Mutual labels:  logger, logging-library
Ring Log
Ring-Log是一个高效简洁的C++异步日志, 其特点是效率高(每秒支持至少125万+日志写入)、易拓展,尤其适用于频繁写日志的场景
Stars: ✭ 201 (+252.63%)
Mutual labels:  logger, logging-library
l
Cross-platform html/io [L]ogger with simple API.
Stars: ✭ 26 (-54.39%)
Mutual labels:  logger, logging-library
Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+6512.28%)
Mutual labels:  logger, logging-library
Quill
Asynchronous Low Latency C++ Logging Library
Stars: ✭ 422 (+640.35%)
Mutual labels:  logger, logging-library
sqlite micro logger arduino
Fast and Lean Sqlite database logger for Microcontrollers
Stars: ✭ 128 (+124.56%)
Mutual labels:  logger, logging-library
sockerl
Sockerl is an advanced Erlang/Elixir socket framework for TCP protocols and provides fast, useful and easy-to-use API for implementing servers, clients and client connection pools.
Stars: ✭ 26 (-54.39%)
Mutual labels:  erlang-developement, erlang-libraries

Build Status

[This document translated on russian](https://github.com/eltex-ecss/chronica/blob/master/README_RU.md)

Overview

Chronica is a framework for logging messages for Erlang OTP Applications.

Features

  • Faster, lightweight, more flexible!
  • Pinning log flows to different outputs (file, tty, network)
  • Custom rules (as regexp) and text formatting for output are supported.
  • Possibility to define text formatting separately for each backend
  • Tools for remote connection allows you to set rule and get back log flow filtered by that rule (grablog)
  • Easy migration from lager
  • Logging functions which are unused because of current verbose level causes no overhead (deleting unused calls for log level on-the-fly)
  • Write on disk in two modes: text and binary
  • Custom backends for output logs
  • Supports unicode
  • Log rotate
  • Colored output to terminal
  • Change log level and rules in runtime
  • Custom tags for easy filtered logs

Usages

In order to add Chronica into your application you will need to add it as Erlang dependency in app file and also set compiler options:

{parse_transform, pt_chronica}

Or add include file in each module if it uses Chronica:

-include_lib("chronica/include/chronica.hrl").

Supported log levels:

(MAX) debug -> trace -> info -> warning -> (MIN) error

And custom tags defines (for easy split on different output flows) as atom in compile time. In all logging messages add service information (module name, line number in source code when located this logging message).

Formats for call log:

log:Level("String"),                 %% log:info("Hello world!")
log:Level("Format", [Args]),         %% log:error("Crush from ~p", [self()])
log:Level(Tag, "Format", [Args]),    %% log:debug(verbose, "Verbose tag", [])
log:Level([Tags], "Format", [Args]), %% log:trace([a, b], "Multiple tag", [])
Tag := atom

Or usage macros: ?DBG, ?TRACE, ?INFO, ?WARN, ?ERR from header file:

-include_lib("chronica/include/chronica_macro.hrl").

Because of function log:Level replace on inner Chronica functions in compile time next example will surprise you:

log:info("My stacktrace: ~p", [erlang:get_stacktrace()])

and replace on

log:info("My stacktrace: %stack", [])

log:todo:

Applies developers instead unused variable:

    garbage() ->
        ...
        TODO_DELETE_THIS_METHOD,
        ...
erlc ...
variable 'TODO_DELETE_THIS_METHOD' is unused

Example:

    garbage() ->
        ...
        log:todo("Delete this method")
        ...
erlc ...
TODO: Delete this method

Configs:

Add default section to sys.config:

{chronica, [
    Rules,
    Flows,
    Formats,
    InternalLogger,
    InternalLoggerFilename,
    LogRoot,
    MaxFileSize,
    MaxFileNum,
    LogIfacePath
   ]}

Example

Options:

Rules:

List rules for filtered log in logging flow. Rule contains name, regexp for filtered message (may be include module, user tags), logging level (error, warning, info, trace, debug) list flow and toggle. Regexp may be contain special character:

  • "|" or
  • "&" and
  • "*" null or more any character
  • "?" one ant character
  • "!" not
{warning_example1, “*”, warning, [warning_file], off},

this rule include all warning message in warning_file flow but turn off,

{warning_example2, “mysql*&!mysql_ag*”, error, [tty, error], on},

this rule include error message from modules beginning mysql besides mysql_ag and output in tty and error flows

Flows:

Named streams for output process and provided backens (tty, file, udp). Include mode for saving data (binary - lightweight for big intensity and text) and name formats.

For example:

{warning_file, [{file, [{name, "warning.log"}]}]},

Define "warning_file" flow output data in file with "warning.log" filename in default format and text mode.

{warning_file, [{file, [{name, "warning.log",}, {format, binary}]}]},

As previous example but in binary mode

{warning_file, [{tty, [{format, custom_format}]}]},

Flow output in terminal in "custom_format" format

{journald, [{journald, [{format, short}]}]},

Flow output in journald (if exist)

Formats:

Define output format for message. Comprises from service macros beginig in '%'. Default configuration already have one formats: 'default', but you may be override him.

Examples:

 {full, "%Id %Y-%M(%Ml)-%D %H:%Mi:%S:%Ms %PRIORITY %P %Priority %Pid %File %Line %Module %Function %Message %MessageLine\n"}
 {default, "%Y-%M-%D %H:%Mi:%S:%Ms %PRIORITY %Pid [%Module:%Line]: %Message\n"},
 {short, "%Y-%M-%D %H:%Mi:%S:%Ms %P %Pid [%Module:%Line]: %Message\n"}
default flow
{flows, [{screen, [{tty, [{format, default}]}]}]}
Out:
    2015-09-27 14:59:32.012401 WARN  <0.130.0> [testing_chronica_logs:testing_short_warning_file/1:57]: test chronica

Override default:

{flows, [{screen, [{tty, [{format, default}]}]}]},
{formats,[{default, "%H:%Mi:%S.%Ms [%Priority] %Message\n"}]},
Out:
    15:03:15.702088 [warning] test chronica

If you want define custom formatter:

{flows, [{file, [{name, "warning_log"}, {format, my_default}]}]},
{formats, [{my_default, “%Message”}]}

Compilation modes

Chronica supports three compilation modes

  • chronica optimization. Optimization mode (Default). In this mode, Chronica allows you to display warnings about variables that are declared in the function body, but are used only in the log:level (...). To avoid receiving warnings, declare variables as \Var_.
  • chronica default. Mode with optimization turned off. Early this mode was the default.
  • chronica disabled. The mode in which chronica cuts out log:level(...).

Compilation Options

Are used to define the behavior at compile time chronica. The options can be set in two ways

  • Using environment variables:
    • CHRONICA_MATCH_IGNORED_VAR
    • CHRONICA_DISABLED
    • CHRONICA_DEFAULT
  • Support erlang compile options
    • chronica_match_ignored_var
    • chronica_disabled
    • chronica_default
  • Declaring the compile(Option) field in the file
    • chronica_match_ignored_var
    • chronica_disabled
    • chronica_default

CHRONICA_MATCH_IGNORED_VAR || chronica_match_ignored_var

This option is used only in the chronica optimization mode and allows you to display warnings about variables that are declared as \Var_

CHRONICA_DISABLED || chronica_disabled

The options is used to activate the mode chronica disabled

CHRONICA_DEFAULT || chronica_default

The options is used to activate the mode chronica default

Runtime API

For update Chronica configuration in runtime usages:

  • chronica_manager:active(false | true)

Toggle chronica

  • chronica_manager:update_rule_inwork(name_rule, false | true)

Toggle "name_rule" rule on the fly.

  • chronica_manager:add_application(App)

Add new application in list logging application

  • chronica_manager:add_rule(Rule, Regexp, Level, Flow)
  • chronica_manager:add_rule(Rule, Regexp, Level, Flow, Fun)

Add new rule in list logging rule and activates

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].