Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #81 from ypaq/master

Added node to metadata in parse transfrom
  • Loading branch information...
commit bf1efd0573228ddd4f6de2cdf65273ee001ee132 2 parents f2f08d1 + 23b26d9
@Vagabond Vagabond authored
View
2  README.org
@@ -95,7 +95,7 @@
as configuration. Any iolist allowed elements in the configuration are printed verbatim. Atoms in the configuration
are treated as metadata properties and extracted from the log message.
The metadata properties date,time, message, and severity will always exist.
- The properties pid, file, line, module, and function will always exist if the parser transform is used.
+ The properties pid, file, line, module, function, and node will always exist if the parser transform is used.
#+BEGIN_EXAMPLE
["Foo"] -> "Foo", regardless of message content.
View
24 src/lager_console_backend.erl
@@ -167,6 +167,30 @@ console_log_test_() ->
end
end
},
+ {"custom format console logging",
+ fun() ->
+ Pid = spawn(F(self())),
+ unregister(user),
+ register(user, Pid),
+ erlang:group_leader(Pid, whereis(lager_event)),
+ gen_event:add_handler(lager_event, lager_console_backend,
+ [info, {lager_default_formatter, [date,"#",time,"#",severity,"#",node,"#",pid,"#",
+ module,"#",function,"#",file,"#",line,"#",message,"\r\n"]}]),
+ lager_mochiglobal:put(loglevel, {?INFO, []}),
+ lager:info("Test message"),
+ PidStr = pid_to_list(self()),
+ NodeStr = atom_to_list(node()),
+ ModuleStr = atom_to_list(?MODULE),
+ receive
+ {io_request, _, _, {put_chars, unicode, Msg}} ->
+ ?assertMatch([_, _, "info", NodeStr, PidStr, ModuleStr, _, _, _, "Test message\r\n"],
+ re:split(Msg, "#", [{return, list}, {parts, 10}]))
+ after
+ 500 ->
+ ?assert(false)
+ end
+ end
+ },
{"tracing should work",
fun() ->
Pid = spawn(F(self())),
View
5 src/lager_transform.erl
@@ -74,7 +74,10 @@ transform_statement({call, Line, {remote, _Line1, {atom, _Line2, lager},
{atom, Line, pid},
{call, Line, {atom, Line, pid_to_list}, [
{call, Line, {atom, Line ,self}, []}]}]},
- {nil, Line}}}}},
+ {cons, Line, {tuple, Line, [
+ {atom, Line, node},
+ {call, Line, {atom, Line, node}, []}]},
+ {nil, Line}}}}}},
{Traces, Message, Arguments} = case Arguments0 of
[Format] ->
{DefaultAttrs, Format, {atom, Line, none}};
Please sign in to comment.
Something went wrong with that request. Please try again.