-module(glimt@serializer@basic). -compile(no_auto_import). -export([level_symbol/1, basic_serializer/1]). -spec level_symbol(glimt@log_message:log_level()) -> binary(). level_symbol(Log_level) -> case Log_level of all -> <<"ALL"/utf8>>; trace -> <<"🔍"/utf8>>; debug -> <<"🐛"/utf8>>; info -> <<"â„šī¸"/utf8>>; warning -> <<"âš ī¸"/utf8>>; error -> <<"❌"/utf8>>; fatal -> <<"đŸ”Ĩ"/utf8>>; none -> <<"NONE"/utf8>> end. -spec style_trace() -> fun((binary()) -> binary()). style_trace() -> _pipe = galant:open(), _pipe@1 = galant:start_dim(_pipe), _pipe@2 = galant:start_cyan(_pipe@1), _pipe@3 = galant:placeholder(_pipe@2), galant:to_string_styler(_pipe@3). -spec style_debug() -> fun((binary()) -> binary()). style_debug() -> _pipe = galant:open(), _pipe@1 = galant:start_cyan(_pipe), _pipe@2 = galant:placeholder(_pipe@1), galant:to_string_styler(_pipe@2). -spec style_info() -> fun((binary()) -> binary()). style_info() -> _pipe = galant:open(), _pipe@1 = galant:start_green(_pipe), _pipe@2 = galant:placeholder(_pipe@1), galant:to_string_styler(_pipe@2). -spec style_error() -> fun((binary()) -> binary()). style_error() -> _pipe = galant:open(), _pipe@1 = galant:start_red(_pipe), _pipe@2 = galant:placeholder(_pipe@1), galant:to_string_styler(_pipe@2). -spec style_fatal() -> fun((binary()) -> binary()). style_fatal() -> _pipe = galant:open(), _pipe@1 = galant:start_bold(_pipe), _pipe@2 = galant:start_red(_pipe@1), _pipe@3 = galant:placeholder(_pipe@2), galant:to_string_styler(_pipe@3). -spec style_warning() -> fun((binary()) -> binary()). style_warning() -> _pipe = galant:open(), _pipe@1 = galant:start_yellow(_pipe), _pipe@2 = galant:placeholder(_pipe@1), galant:to_string_styler(_pipe@2). -spec style_plain() -> fun((binary()) -> binary()). style_plain() -> _pipe = galant:open(), _pipe@1 = galant:placeholder(_pipe), galant:to_string_styler(_pipe@1). -spec style_level(glimt@log_message:log_level()) -> fun((binary()) -> binary()). style_level(Log_level) -> case Log_level of all -> style_plain(); trace -> style_trace(); debug -> style_debug(); info -> style_info(); warning -> style_warning(); error -> style_error(); fatal -> style_fatal(); none -> style_plain() end. -spec style_name(binary()) -> binary(). style_name(Name) -> _pipe = galant:open(), _pipe@1 = galant:magenta(_pipe, Name), galant:to_string(_pipe@1). -spec style_time(binary()) -> binary(). style_time(Time) -> _pipe = galant:open(), _pipe@1 = galant:dim(_pipe, Time), galant:to_string(_pipe@1). -spec full_name( binary(), gleam@erlang@process:pid_(), gleam@option:option(binary()), gleam@option:option(gleam@erlang@process:pid_()) ) -> binary(). full_name(Name, Pid, Instance_name, Instance_pid) -> case {Instance_name, Instance_pid} of {{some, Instance_name@1}, {some, Instance_pid@1}} -> <<<<<<<<<<<<<>/binary, (gleam@erlang:format(Pid))/binary>>/binary, ")/"/utf8>>/binary, Instance_name@1/binary>>/binary, "("/utf8>>/binary, (gleam@erlang:format(Instance_pid@1))/binary>>/binary, ")"/utf8>>; {{some, Instance_name@2}, none} -> <<<<<<<>/binary, (gleam@erlang:format(Pid))/binary>>/binary, ")/"/utf8>>/binary, Instance_name@2/binary>>; {none, {some, Instance_pid@2}} -> <<<<<<<<<<<<<>/binary, (gleam@erlang:format(Pid))/binary>>/binary, ")/"/utf8>>/binary, "???"/utf8>>/binary, "("/utf8>>/binary, (gleam@erlang:format(Instance_pid@2))/binary>>/binary, ")"/utf8>>; {none, none} -> <<<<<>/binary, (gleam@erlang:format(Pid))/binary>>/binary, ")"/utf8>> end. -spec basic_serializer( glimt@log_message:log_message(any(), any(), gleam@dynamic:dynamic()) ) -> binary(). basic_serializer(Log_message) -> {log_message, Time@1, Name@1, Pid@1, Instance_name@1, Instance_pid@1, Level@1, _@4, Message@1, Error@1, _@5, _@6} = case Log_message of {log_message, Time, Name, Pid, Instance_name, Instance_pid, Level, _@1, Message, Error, _@2, _@3} -> {log_message, Time, Name, Pid, Instance_name, Instance_pid, Level, _@1, Message, Error, _@2, _@3}; _try -> erlang:error(#{gleam_error => assert, message => <<"Assertion pattern match failed"/utf8>>, value => _try, module => <<"glimt/serializer/basic"/utf8>>, function => <<"basic_serializer"/utf8>>, line => 125}) end, Styled_time = style_time(Time@1), Styled_level = begin _pipe = glimt@log_message:level_string(Level@1), (style_level(Level@1))(_pipe) end, Styled_message = Message@1, Error_string = case Error@1 of {some, Err} -> <<" | "/utf8, (gleam@string:inspect(Err))/binary>>; none -> <<""/utf8>> end, Styled_name = begin _pipe@1 = Name@1, _pipe@2 = full_name(_pipe@1, Pid@1, Instance_name@1, Instance_pid@1), style_name(_pipe@2) end, <<<<<<<<<<<<<>/binary, Styled_level/binary>>/binary, " | "/utf8>>/binary, Styled_name/binary>>/binary, " | "/utf8>>/binary, Styled_message/binary>>/binary, Error_string/binary>>.