{"id":15056420,"url":"https://github.com/sile/logi_stdlib","last_synced_at":"2026-01-02T05:03:41.657Z","repository":{"id":57518277,"uuid":"44479284","full_name":"sile/logi_stdlib","owner":"sile","description":"The standard library for logi: https://github.com/sile/logi","archived":false,"fork":false,"pushed_at":"2018-09-27T14:13:42.000Z","size":2706,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-27T01:45:12.012Z","etag":null,"topics":["erlang","logger"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-18T13:35:19.000Z","updated_at":"2023-07-25T13:58:23.000Z","dependencies_parsed_at":"2022-09-26T18:01:36.574Z","dependency_job_id":null,"html_url":"https://github.com/sile/logi_stdlib","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/sile/logi_stdlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Flogi_stdlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Flogi_stdlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Flogi_stdlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Flogi_stdlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sile","download_url":"https://codeload.github.com/sile/logi_stdlib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Flogi_stdlib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28126927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-30T02:00:05.476Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erlang","logger"],"created_at":"2024-09-24T21:51:09.611Z","updated_at":"2026-01-02T05:03:41.629Z","avatar_url":"https://github.com/sile.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"logi_stdlib\n===========\n\n[![hex.pm version](https://img.shields.io/hexpm/v/logi_stdlib.svg)](https://hex.pm/packages/logi_stdlib)\n[![Build Status](https://travis-ci.org/sile/logi_stdlib.svg?branch=master)](https://travis-ci.org/sile/logi_stdlib)\n[![Code Coverage](https://codecov.io/gh/sile/logi_stdlib/branch/master/graph/badge.svg)](https://codecov.io/gh/sile/logi_stdlib/branch/master)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nStandard library for [logi](https://github.com/sile/logi)\n\nBuild\n-----\n\nThe build tool is [rebar3](https://github.com/erlang/rebar3).\n\nAdd following code to your `rebar.config` file:\n```erlang\n{deps,\n [\n   logi_stdlib\n ]}.\n```\n\nStarts erlang shell:\n```erlang\n$ rebar3 shell\n\n\u003e application:ensure_all_started(logi_stdlib).\n\u003e error_logger:tty(false). % Suppresses annoying warnings for the sake of brevity\n\n\u003e {ok, _} = logi_channel:install_sink(logi_sink_console:new(sample), info).\n\u003e logi:info(\"Hello World!\").\n2016-05-09 13:15:54.758 [info] nonode@nohost \u003c0.88.0\u003e erl_eval:do_apply:674 [] Hello World!\n```\n\nAPI\n---\n\nSee [EDoc Documents](https://hexdocs.pm/logi_stdlib/)\n\nUsage Examples\n--------------\n\n### Outputs to console and file\n\n```erlang\n%%% Installs sinks\n\u003e ConsoleSink = logi_sink_console:new(console).\n\u003e FileSink = logi_sink_file:new(file, \"/tmp/alert.log\").\n\u003e {ok, _} = logi_channel:install_sink(ConsoleSink, info).\n\u003e {ok, _} = logi_channel:install_sink(FileSink, alert).\n\n%%% Log messages\n%% info log\n\u003e logi:info(\"Hello World!\").\n2016-05-09 13:19:55.327 [info] nonode@nohost \u003c0.88.0\u003e erl_eval:do_apply:674 [] Hello World!\n\n\u003e file:read_file(\"/tmp/alert.log\").\n{ok, \u003c\u003c\u003e\u003e}\n\n%% alert log\n\u003e logi:alert(\"Something Wrong\").\n2016-05-09 13:21:04.953 [alert] nonode@nohost \u003c0.88.0\u003e erl_eval:do_apply:674 [] Something Wrong\n\n\u003e file:read_file(\"/tmp/alert.log\").\n{ok,\u003c\u003c\"2016-05-09 13:21:04.953 [alert] nonode@nohost \u003c0.88.0\u003e erl_eval:do_apply:674 [] Something Wrong\\n\"\u003e\u003e}\n```\n\n### Forwards error_logger messages\n\n```erlang\n%%% Installs sinks\n\u003e {ok, _} = logi_channel:install_sink(logi_sink_console:new(console), info).\n\n%%% Installs logi's error_logger handler\n\u003e ok = logi_source_error_logger:install().\n\n%%% Log messages via error_logger module\n\u003e error_logger:info_msg(\"Hello World!\").\n2016-05-09 13:28:43.575 [info] nonode@nohost \u003c0.5.0\u003e logi_source_error_logger:default_log_fun:144 [gleader=\u003c0.86.0\u003e,sender=\u003c0.88.0\u003e] Hello World!\n```\n\n### Limits log messages size\n\n```erlang\n%%% Installs sinks\n\u003e Layout = logi_layout_newline:new(logi_layout_limit:new(logi_layout_default:new(), [{max_size, 32}])). % limit: 32 bytes\n\u003e Sink = logi_sink_console:new(console, Layout).\n\u003e {ok, _} = logi_channel:install_sink(Sink, info).\n\n%%% Log messages\n\u003e logi:info(\"Hello World!\").\n2016-05-09 13:33:23.840 [info] n...59...  % Tail of the long message was abbreviated\n```\n\n### Frequency control per logger\n\n```erlang\n%%% Installs sinks\n\u003e {ok, _} = logi_channel:install_sink(logi_sink_console:new(console), info).\n\n%%% Setup logger instance with a logi_filter_frequency filter\n%%% LIMIT: 3 messages per second\n\u003e logi:save_as_default(logi:new([{filter, logi_filter_frequency:new([{max_count, 3}, {period, 1000}])}])).\n\n%%% Log messages\n\u003e lists:foreach(fun (I) -\u003e logi:info(\"Hello: ~p\", [I]) end, lists:seq(1, 10)).\n2016-05-09 13:41:29.150 [info] nonode@nohost \u003c0.195.0\u003e lists:foreach:1337 [] Hello: 1\n2016-05-09 13:41:29.150 [info] nonode@nohost \u003c0.195.0\u003e lists:foreach:1337 [] Hello: 2\n2016-05-09 13:41:29.151 [info] nonode@nohost \u003c0.195.0\u003e lists:foreach:1337 [] Hello: 3\n\n\u003e timer:sleep(1000).\n\n\u003e logi:info(\"World!\").\n2016-05-09 13:41:30.812 [info] nonode@nohost \u003c0.195.0\u003e lists:foreach:1337 [] Over a period of 1.661 seconds, 7 messages were dropped\n2016-05-09 13:41:30.812 [info] nonode@nohost \u003c0.195.0\u003e erl_eval:do_apply:674 [] World!\n```\n\n### Frequency control per sink\n\n```erlang\n%%% Installs sinks\n%%% LIMITE: 300 bytes per second\n\u003e Sink = logi_sink_flow_limiter:new(limiter, logi_sink_console:new(console), [{write_rate_limits, [{300, 1000}]}]).\n\u003e {ok, _} = logi_channel:install_sink(Sink, info).\n\n%%% Log messages\n\u003e lists:foreach(fun (I) -\u003e logi:info(\"Hello: ~p\", [I]) end, lists:seq(1, 10)).\n2016-05-09 13:48:26.160 [info] nonode@nohost \u003c0.105.0\u003e lists:foreach:1337 [] Hello: 1\n2016-05-09 13:48:26.171 [info] nonode@nohost \u003c0.105.0\u003e lists:foreach:1337 [] Hello: 2\n2016-05-09 13:48:26.172 [info] nonode@nohost \u003c0.105.0\u003e lists:foreach:1337 [] Hello: 3\n2016-05-09 13:48:26.172 [info] nonode@nohost \u003c0.105.0\u003e lists:foreach:1337 [] Hello: 4\n\n\u003e timer:sleep(1000).\n\n\u003e logi:info(\"World!\").\n2016-05-09 13:48:43.768 [info] nonode@nohost \u003c0.105.0\u003e erl_eval:do_apply:674 [] World!\n2016-05-09 13:49:01.889 [warning] nonode@nohost \u003c0.111.0\u003e logi_sink_flow_limiter_writer:report_omissions:189 [] Over a period of 60 seconds, 6 info messages were omitted: channel=logi_default_log, reason=rate_exceeded (e.g. [{pid,module,line},{\u003c0.105.0\u003e,lists,1337}])\n```\n\n### High Availability Configuration\n\n```erlang\n%%% Installs sinks\n\u003e File1 = logi_sink_file:new(file1, \"/tmp/file1.log\").\n\u003e File2 = logi_sink_file:new(file2, \"/tmp/file2.log\").\n\u003e Sink = logi_sink_ha:new(ha, [#{sink =\u003e File1}, #{sink =\u003e File2}], [{strategy, first_available}, {logger, null}]).\n\u003e {ok, _} = logi_channel:install_sink(Sink, info).\n\n%%% Log messages\n\n%% First available sink is `file1`\n\u003e logi:info(\"Hello\").\n\u003e file:read_file(\"/tmp/file1.log\").\n{ok,\u003c\u003c\"2016-05-09 13:55:38.410 [info] nonode@nohost \u003c0.88.0\u003e erl_eval:do_apply:674 [] Hello\\n\"\u003e\u003e}\n\u003e file:read_file(\"/tmp/file2.log\").\n{ok,\u003c\u003c\u003e\u003e}\n\n%% Removes permission of file1 and forces reopen\n\u003e file:change_mode(\"/tmp/file1.log\", 0).\n\u003e exit(logi_channel:whereis_sink_proc([ha, file1]), kill).\n\n%% Now, first available sink is `file2`\n\u003e logi:info(\"World!\").\n\u003e file:read_file(\"/tmp/file2.log\").\n{ok,\u003c\u003c\"2016-05-09 03:59:06.420 [info] nonode@nohost \u003c0.88.0\u003e erl_eval:do_apply:674 [] World!\\n\"\u003e\u003e}\n```\n\nLicense\n-------\n\nThis library is released under the MIT License.\n\nSee the [LICENSE](LICENSE) file for full license information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Flogi_stdlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsile%2Flogi_stdlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Flogi_stdlib/lists"}