-
-
Save garazdawi/6319ef80d3b969ebbed5633f11a807b1 to your computer and use it in GitHub Desktop.
eunit logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(logger_test). | |
-include_lib("eunit/include/eunit.hrl"). | |
-export([function_that_logs/0, function_that_logs_and_fails/0]). | |
-export([log/2]). | |
function_that_logs() -> | |
logger:error("Log me please"). | |
function_that_logs_and_fails() -> | |
logger:error("Log me please"), | |
?assert(ok == nok). | |
logs_test_() -> | |
{setup, | |
fun() -> | |
logger:add_handler(?MODULE,?MODULE, | |
#{ level => all }), | |
logger:update_handler_config(default,level,none) | |
end, | |
fun(_) -> | |
logger:update_handler_config(default,level,notice), | |
logger:remove_handler(?MODULE) end, | |
[fun function_that_logs/0, | |
fun function_that_logs_and_fails/0] | |
}. | |
log(#{ meta := #{ gl := Gl} } = Log, _Config) -> | |
io:format(Gl, "~ts",[logger_formatter:format(Log, #{})]), | |
ok. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment