Don't use dirty timeout for gen_statem
That was introduced in OTP 19.2, and causes
failures in tests on OTP 19 and 19.1
Fix statem for all 19.x releases
Previously, error_logger messages only had the pid of the crashed
process, not any of the traditional lager metadata like
module, function, line, etc.
It turns out, however, that we already have most if not all of that
information as metadata already in the stack trace. Thus, we can capture
it and re-inject the error logger log message as a lager message with
metadata.
Additionally, when a process crashes, we get the process dictionary
passed to us, which we can scan for the '_lager_metadata' entry, and
attach the dead process' metadata to the log message as well.
On final analysis, it appears the effective fix is clearing out leftover lager state in the application controller.
Along the way, the test body was modified to account for the runtime system, and as this doesn't seem like a bad thing it's left in place.
This commit also moves `otp_version/0` to `lager_util`'s public API, as it may be helpful in future tests that check for version-specific messages (see issue #383).
Uses lager_util:create_test_dir/0 and lager_util:delete_test_dir/1 to give tests, or groups thereof, their own clean directory to work in.
Turn off whitespace diffs to review, as much code is shifted left to allow sane wrapping within around 100 columns.
Change rotate_file_test/0 and rotate_file_fail_test/0 to use temporary test directories.
Refactor rotate_file_test/0 to be marginally understandable.
Fix rotate_file_fail_test/0 to use 'chmod', as intended, instead of 'chown'.
This allows users to log metadata (tuple list) without a format string in lager. For
example `lager:info([{foo, bar}])` instead of `lager:info([{foo,bar}], "")`.
Add `| undefined` to records that get initialized with not all their
fields set to the proper type (hence get the value undefined). These
fixes allow lager to exist as a dependency in a project and be filtered
through that project's dialyzer run without warnings.
The strict configuration work in 31cf6c0 prevents some
backwards-compatible code in lager_file_backend from working as the
configuration is rejected before it gets to the backend. This fix adds
an additional guard on `check_handler_config/2` to support the `tuple`
configuration structure supported by `lager_file_backend`.
Applications that explicitly configure lager's `crash_log` with the
value `undefined` will get a really terrible crash message for all
versions since 81222ca486
Diff here: 81222ca486 (diff-25e915f0df09d04052d2a6e85b8824f2)
That message looks like this:
```
** Generic server lager_crash_log terminating
** Last message in was rotate
** When Server state == {state,undefined,
{file_descriptor,prim_file,{#Port<0.1340>,15}},
281571,65536,10485760,
[{hour,0}],
5,false}
** Reason for termination ==
** {badarg,[{erlang,'++',[undefined,".3"],[]},
{lager_util,rotate_logfile,2,
[{file,"_build/default/lib/lager/src/lager_util.erl"},
{line,220}]},
{lager_crash_log,handle_info,2,
[{file,"_build/default/lib/lager/src/lager_crash_log.erl"},
{line,99}]},
{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,601}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,667}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
```
This fix will allow people who use this legacy configuration to not
experience production crashes at midnight after the deploy, when
crash_log tries to rotate for the very first time, resulting in trying
to append `.Int` to `undefined`