Prior to this change, lager would simply rename all the files and leave
the 'base' filename empty until a log event came into create it. This
caused confusion with users and tooling.
The fix, as suggested by Shamis Shukoor, is to not delete/rename the
base file, but simply try to open it in write only mode. This will
create the file if it does not exist and truncate it if it does.
Co-authored-by: Shamis Shukoor <shamis657@gmail.com>
To support tracing to a console that is not the erlang node's *direct*
console introduce 2 additional options to the console backend:
`group_leader` and `id`. Group leader allows to use io:put_chars to send
the console output to a remote pid (eg. the group leader on a node
created by nodetool) and the ID allows multiple console backends to
exist simultaneously (for example {lager_console_backend, NodeName}).
Additionally, to support ephemeral console backends with associated
traces, if the console handler explicitly removes itself from the event
handler, remove any traces for that id.
To facilitate this, a new function has been added to the lager module:
`lager:clear_trace_by_destination/1`.
To support OTP 21 we manually start error_logger if it is not present
(and lager is configured to install an error_logger handler) and we add
error_logger as a logger handler.
Longer term we should switch to installing our own logger handler, but
that is a larger task as we'd have to redo all the event parsing, if
that is even possible.
Closes#309. This will enable the use of `node`
in log formatting. It uses the value of the node()
function via atom_to_list/1 to output a value.
There is a simple test case.