Permalink
Browse files

Merge pull request #112 from ewanmellor/non-atom-levels

Improve lager_console_backend to support non-atom output log levels.
  • Loading branch information...
2 parents 467204d + 4e3ea7b commit 7993c8f8a2626b91babd27d1153c63d6a0001589 @Vagabond Vagabond committed Mar 2, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/lager_console_backend.erl
@@ -36,13 +36,11 @@
-define(TERSE_FORMAT,[time, " [", severity,"] ", message, "\r\n"]).
%% @private
-init(Level) when is_atom(Level) ->
- init([Level,{lager_default_formatter,?TERSE_FORMAT}]);
init([Level, true]) -> % for backwards compatibility
init([Level,{lager_default_formatter,[{eol, "\r\n"}]}]);
init([Level,false]) -> % for backwards compatibility
init([Level,{lager_default_formatter,?TERSE_FORMAT}]);
-init([Level,{Formatter,FormatterConfig}]) when is_atom(Level), is_atom(Formatter)->
+init([Level,{Formatter,FormatterConfig}]) when is_atom(Formatter) ->
try lager_util:config_to_mask(Level) of
Levels ->
{ok, #state{level=Levels,
@@ -51,7 +49,9 @@ init([Level,{Formatter,FormatterConfig}]) when is_atom(Level), is_atom(Formatte
catch
_:_ ->
{error, bad_log_level}
- end.
+ end;
+init(Level) ->
+ init([Level,{lager_default_formatter,?TERSE_FORMAT}]).
%% @private

0 comments on commit 7993c8f

Please sign in to comment.