diff --git a/README.md b/README.md index 4f2ca69..db78bef 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/test/lager_test_backend.erl b/test/lager_test_backend.erl index 5d1f68e..6286235 100644 --- a/test/lager_test_backend.erl +++ b/test/lager_test_backend.erl @@ -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 } ] }.