Selaa lähdekoodia

Merge branch 'doobinay-utc-time'

pull/359/merge
Mark Allen 8 vuotta sitten
vanhempi
commit
d041f3d6f9
2 muutettua tiedostoa jossa 36 lisäystä ja 0 poistoa
  1. +16
    -0
      README.md
  2. +20
    -0
      test/lager_test_backend.erl

+ 16
- 0
README.md Näytä tiedosto

@ -237,6 +237,22 @@ Examples:
[{server,{pid, ["(", pid, ")"], ["(Unknown Server)"]}}] -> user provided server metadata, otherwise "(<?.?.?>)", otherwise "(Unknown Server)"
```
Universal time
--------------
By default, lager formats timestamps as local time for whatever computer
generated the log message.
To make lager use UTC timestamps, you can set the `sasl` application's
`utc_log` configuration parameter to `true` in your application configuration
file.
Example:
```
%% format log timestamps as UTC
[{sasl, [{utc_log, true}]}].
```
Error logger integration
------------------------
Lager is also supplied with a `error_logger` handler module that translates

+ 20
- 0
test/lager_test_backend.erl Näytä tiedosto

@ -696,6 +696,26 @@ lager_test_() ->
?assertError(badarg, lager:md("zookeeper zephyr")),
ok
end
},
{"dates should be local by default",
fun() ->
lager:warning("so long, and thanks for all the fish"),
?assertEqual(1, count()),
{_Level, {_Date, Time}, _Message, _Metadata} = pop(),
?assertEqual(nomatch, binary:match(iolist_to_binary(Time), <<"UTC">>)),
ok
end
},
{"dates should be UTC if SASL is configured as UTC",
fun() ->
application:set_env(sasl, utc_log, true),
lager:warning("so long, and thanks for all the fish"),
application:set_env(sasl, utc_log, false),
?assertEqual(1, count()),
{_Level, {_Date, Time}, _Message, _Metadata} = pop(),
?assertNotEqual(nomatch, binary:match(iolist_to_binary(Time), <<"UTC">>)),
ok
end
}
]
}.

Ladataan…
Peruuta
Tallenna