Skip to content

Commit

Permalink
Switch to logger (#442)
Browse files Browse the repository at this point in the history
* Switch to logger

Use logger rather than io:format when logging.  The ct tests have besn switched to log to file, testutil/init_per_suite/1 may offer useful guidance on configuring logger with leveled.

As all logs are produced by the leveled_log module, the MFA metadata is uninteresting for log outputs, but can be used for explicit filter controls for leveled logs.

* iolist_to_binary not unicode_binary()

logger filters will be error and be removed if the format line is a binary().  Must be either a charlist() or a unicode_binary() - so iolist_to_binary() can't be used

* Add metadata for filter

* Update test/end_to_end/tictac_SUITE.erl

Co-authored-by: Thomas Arts <[email protected]>

---------

Co-authored-by: Thomas Arts <[email protected]>
  • Loading branch information
martinsumner and ThomasArts authored Sep 6, 2024
1 parent 5db277b commit 54e3096
Show file tree
Hide file tree
Showing 27 changed files with 492 additions and 410 deletions.
11 changes: 8 additions & 3 deletions priv/leveled.schema
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,18 @@
]}.

%% @doc Log level
%% Can be debug, info, warn, error or critical
%% Can be debug, info, warning, error or critical
%% Set the minimum log level to be used within leveled. Leveled will log many
%% lines to allow for stats to be etracted by those using log indexers such as
%% Splunk
%% Splunk.
%% Logging will be via erlang logger, and so the destination will be defined
%% by the configured log handlers of the erlang node which starts the bookie.
%% All logs are from the leveled_log module, and so specific handling can be
%% managed using filters on the first element of the MFS metadata, or setting
%% the log level for that specific module.
{mapping, "leveled.log_level", "leveled.log_level", [
{default, info},
{datatype, atom}
{datatype, {enum, [debug, info, warning, error, critical]}}
]}.

%% @doc The approximate size (in bytes) when a Journal file should be rolled.
Expand Down
6 changes: 3 additions & 3 deletions src/leveled.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{vsn, git},
{registered, []},
{applications, [
lz4,
zstd,
kernel,
stdlib
stdlib,
lz4,
zstd
]},
{maintainers, ["Martin Sumner"]},
{licenses, ["Apache"]},
Expand Down
2 changes: 1 addition & 1 deletion src/leveled_bookie.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

-behaviour(gen_server).

-include("include/leveled.hrl").
-include("leveled.hrl").

-export([init/1,
handle_call/3,
Expand Down
4 changes: 1 addition & 3 deletions src/leveled_cdb.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@
%% The first word is the corresponding hash value and the second word is a
%% file pointer to the actual {key,value} tuple higher in the file.
%%
%%


-module(leveled_cdb).

-behaviour(gen_statem).
-include("include/leveled.hrl").
-include("leveled.hrl").

-export([init/1,
callback_mode/0,
Expand Down
2 changes: 1 addition & 1 deletion src/leveled_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

-module(leveled_codec).

-include("include/leveled.hrl").
-include("leveled.hrl").

-export([
inker_reload_strategy/1,
Expand Down
2 changes: 1 addition & 1 deletion src/leveled_head.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

-module(leveled_head).

-include("include/leveled.hrl").
-include("leveled.hrl").

-export([key_to_canonicalbinary/1,
build_head/2,
Expand Down
2 changes: 1 addition & 1 deletion src/leveled_iclerk.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

-behaviour(gen_server).

-include("include/leveled.hrl").
-include("leveled.hrl").

-export([init/1,
handle_call/3,
Expand Down
3 changes: 0 additions & 3 deletions src/leveled_imanifest.erl
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
%% -------- Inker Manifest ---------
%%


-module(leveled_imanifest).

-include("include/leveled.hrl").

-export([
generate_entry/1,
add_entry/3,
Expand Down
3 changes: 1 addition & 2 deletions src/leveled_inker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,11 @@
%% TODO: how to instruct the files to close is tbd
%%


-module(leveled_inker).

-behaviour(gen_server).

-include("include/leveled.hrl").
-include("leveled.hrl").

-export([init/1,
handle_call/3,
Expand Down
Loading

0 comments on commit 54e3096

Please sign in to comment.