Browse Source

Add pid to the list of attributes automatically captured for tracing

pull/24/head
Andrew Thompson 13 years ago
parent
commit
ed7bc9a8a8
2 changed files with 16 additions and 4 deletions
  1. +8
    -1
      README.org
  2. +8
    -3
      src/lager_transform.erl

+ 8
- 1
README.org View File

@ -159,7 +159,7 @@
* Tracing * Tracing
Lager supports basic support for redirecting log messages based on log message Lager supports basic support for redirecting log messages based on log message
attributes. Lager automatically captures the module, function and line at the
attributes. Lager automatically captures the pid, module, function and line at the
log message callsite. However, you can add any additional attributes you wish: log message callsite. However, you can add any additional attributes you wish:
#+BEGIN_EXAMPLE #+BEGIN_EXAMPLE
@ -207,3 +207,10 @@
... ...
lager:stop_trace(Trace) lager:stop_trace(Trace)
#+END_EXAMPLE #+END_EXAMPLE
Tracing to a pid is somewhat of a special case, since a pid is not a
data-type that serializes well. To trace by pid, use the pid as a string:
#+BEGIN_EXAMPLE
lager:trace_console([{pid, "<0.410.0>"}])
#+END_EXAMPLE

+ 8
- 3
src/lager_transform.erl View File

@ -65,9 +65,14 @@ transform_statement({call, Line, {remote, Line1, {atom, Line2, lager},
{atom, Line, module}, {atom, Line, get(module)}]}, {atom, Line, module}, {atom, Line, get(module)}]},
{cons, Line, {tuple, Line, [ {cons, Line, {tuple, Line, [
{atom, Line, function}, {atom, Line, get(function)}]}, {atom, Line, function}, {atom, Line, get(function)}]},
{cons, Line, {tuple, Line, [{atom, Line, line}, {integer,
Line, Line}]},
{nil, Line}}}},
{cons, Line, {tuple, Line, [
{atom, Line, line},
{integer, Line, Line}]},
{cons, Line, {tuple, Line, [
{atom, Line, pid},
{call, Line, {atom, Line, pid_to_list}, [
{call, Line, {atom, Line ,self}, []}]}]},
{nil, Line}}}}},
{Traces, Arguments} = case Arguments0 of {Traces, Arguments} = case Arguments0 of
[Format] -> [Format] ->
{DefaultAttrs, [Format, {nil, Line}]}; {DefaultAttrs, [Format, {nil, Line}]};

Loading…
Cancel
Save