aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2018-05-23 12:34:30 +0200
committerSiri Hansen <[email protected]>2018-05-23 12:48:25 +0200
commit72f1ce276401e0b8de9c0c527cbc324da0186939 (patch)
treeee9213c25a48b2766b5659838ad2a1d1ab0f2cbf
parent80606372f163ac26980010ee64464b2ace412100 (diff)
downloadotp-72f1ce276401e0b8de9c0c527cbc324da0186939.tar.gz
otp-72f1ce276401e0b8de9c0c527cbc324da0186939.tar.bz2
otp-72f1ce276401e0b8de9c0c527cbc324da0186939.zip
Change type name logger:log() to logger:log_event()
-rw-r--r--lib/kernel/doc/src/logger.xml18
-rw-r--r--lib/kernel/doc/src/logger_chapter.xml26
-rw-r--r--lib/kernel/src/error_logger.erl2
-rw-r--r--lib/kernel/src/logger.erl21
-rw-r--r--lib/kernel/src/logger_backend.erl4
-rw-r--r--lib/kernel/src/logger_disk_log_h.erl8
-rw-r--r--lib/kernel/src/logger_filters.erl50
-rw-r--r--lib/kernel/src/logger_formatter.erl4
-rw-r--r--lib/kernel/src/logger_h_common.erl8
-rw-r--r--lib/kernel/src/logger_std_h.erl8
-rw-r--r--lib/kernel/test/logger_formatter_SUITE.erl2
11 files changed, 76 insertions, 75 deletions
diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml
index d6576db6f3..bb356c5b86 100644
--- a/lib/kernel/doc/src/logger.xml
+++ b/lib/kernel/doc/src/logger.xml
@@ -87,7 +87,7 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro
</desc>
</datatype>
<datatype>
- <name name="log"/>
+ <name name="log_event"/>
<desc>
<p></p>
</desc>
@@ -446,7 +446,7 @@ Current logger configuration:
<p>The return value of the fun specifies if a log event is to
be discarded or forwarded to the handlers:</p>
<taglist>
- <tag><c>log()</c></tag>
+ <tag><c>log_event()</c></tag>
<item>
<p>The filter <em>passed</em>. The next logger filter, if
any, is applied. If no more logger filters exist, the
@@ -487,7 +487,7 @@ Current logger configuration:
<p>The return value of the fun specifies if a log event is to
be discarded or forwarded to the handler callback:</p>
<taglist>
- <tag><c>log()</c></tag>
+ <tag><c>log_event()</c></tag>
<item>
<p>The filter <em>passed</em>. The next handler filter, if
any, is applied. If no more filters exist for this
@@ -929,11 +929,11 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
</func>
<func>
- <name>HModule:log(Log,Config) -> void()</name>
+ <name>HModule:log(LogEvent,Config) -> void()</name>
<fsummary>Log the given log event.</fsummary>
<type>
- <v>Log =
- <seealso marker="#type-log">log()</seealso></v>
+ <v>LogEvent =
+ <seealso marker="#type-log_event">log_event()</seealso></v>
<v>Config =
<seealso marker="#type-config">config()</seealso></v>
</type>
@@ -979,11 +979,11 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
<funcs>
<func>
- <name>FModule:format(Log,FConfig) -> FormattedLogEntry</name>
+ <name>FModule:format(LogEvent,FConfig) -> FormattedLogEntry</name>
<fsummary>Format the given log event.</fsummary>
<type>
- <v>Log =
- <seealso marker="#type-log">log()</seealso></v>
+ <v>LogEvent =
+ <seealso marker="#type-log_event">log_event()</seealso></v>
<v>FConfig =
<seealso marker="#type-formatter_config">formatter_config()</seealso></v>
<v>FormattedLogEntry =
diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml
index dff9ee2892..3b4cafb010 100644
--- a/lib/kernel/doc/src/logger_chapter.xml
+++ b/lib/kernel/doc/src/logger_chapter.xml
@@ -252,7 +252,7 @@
<p>A handler is defined as a module exporting at least the
following function:</p>
- <pre><seealso marker="logger#HModule:log-2">log(Log, Config)</seealso></pre>
+ <pre><seealso marker="logger#HModule:log-2">log(LogEvent, Config)</seealso></pre>
<p>This function is called when a log event has passed through all
global filters, and all handler filters attached to the handler
@@ -320,7 +320,7 @@
module, <c>FModule</c> and its
configuration, <c>FConfig</c>. <c>FModule</c> must export the
following function, which can be called by the handler:</p>
- <pre><seealso marker="logger#FModule:format-2">format(Log,FConfig)
+ <pre><seealso marker="logger#FModule:format-2">format(LogEvent,FConfig)
-> FormattedLogEntry</seealso></pre>
<p>See the <seealso marker="logger_formatter">
<c>logger_formatter(3)</c></seealso> manual for the full
@@ -735,7 +735,7 @@ ok</pre>
<title>Example: implement a handler</title>
<p>The only requirement that a handler MUST fulfill is to export
the following function:</p>
- <code>log(logger:log(),logger:config()) ->ok</code>
+ <code>log(logger:log_event(),logger:config()) -> ok</code>
<p>It may also implement the following callbacks:</p>
<code>
adding_handler(logger:config()) -> {ok,logger:config()} | {error,term()}
@@ -763,8 +763,8 @@ changing_config(logger:config(),logger:config()) -> {ok,logger:config()} | {erro
-module(myhandler).
-export([log/2]).
-log(Log,#{formatter:={FModule,FConfig}) ->
- io:put_chars(FModule:format(Log,FConfig)).
+log(LogEvent,#{formatter:={FModule,FConfig}) ->
+ io:put_chars(FModule:format(LogEvent,FConfig)).
</code>
<p>A simple handler which prints to file could be implemented like
@@ -782,8 +782,8 @@ removing_handler(#{myhandler_fd:=Fd}) ->
_ = file:close(Fd),
ok.
-log(Log,#{myhandler_fd:=Fd,formatter:={FModule,FConfig}}) ->
- io:put_chars(Fd,FModule:format(Log,FConfig)).
+log(LogEvent,#{myhandler_fd:=Fd,formatter:={FModule,FConfig}}) ->
+ io:put_chars(Fd,FModule:format(LogEvent,FConfig)).
</code>
<note><p>The above handlers do not have any overload
@@ -810,8 +810,8 @@ adding_handler(Config) ->
removing_handler(#{myhandler_pid:=Pid}) ->
gen_server:stop(Pid).
-log(Log,#{myhandler_pid:=Pid} = Config) ->
- gen_server:cast(Pid,{log,Log,Config}).
+log(LogEvent,#{myhandler_pid:=Pid} = Config) ->
+ gen_server:cast(Pid,{log,LogEvent,Config}).
init(#{myhandler_file:=File}) ->
{ok,Fd} = file:open(File,[append,{encoding,utf8}]),
@@ -820,16 +820,16 @@ init(#{myhandler_file:=File}) ->
handle_call(_,_,State) ->
{reply,{error,bad_request},State}.
-handle_cast({log,Log,Config},#{fd:=Fd} = State) ->
- do_log(Fd,Log,Config),
+handle_cast({log,LogEvent,Config},#{fd:=Fd} = State) ->
+ do_log(Fd,LogEvent,Config),
{noreply,State}.
terminate(Reason,#{fd:=Fd}) ->
_ = file:close(Fd),
ok.
-do_log(Fd,Log,#{formatter:={FModule,FConfig}}) ->
- String = FModule:format(Log,FConfig),
+do_log(Fd,LogEvent,#{formatter:={FModule,FConfig}}) ->
+ String = FModule:format(LogEvent,FConfig),
io:put_chars(Fd,String).
</code>
</section>
diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl
index 96f6536e61..b3957d0c7e 100644
--- a/lib/kernel/src/error_logger.erl
+++ b/lib/kernel/src/error_logger.erl
@@ -116,7 +116,7 @@ removing_handler(#{id:=?MODULE}) ->
stop(),
ok.
--spec log(logger:log(),logger:config()) -> ok.
+-spec log(logger:log_event(),logger:config()) -> ok.
log(#{level:=Level,msg:=Msg,meta:=Meta},_Config) ->
do_log(Level,Msg,Meta).
diff --git a/lib/kernel/src/logger.erl b/lib/kernel/src/logger.erl
index f35036aa04..12f8dd77cf 100644
--- a/lib/kernel/src/logger.erl
+++ b/lib/kernel/src/logger.erl
@@ -64,11 +64,11 @@
%%%-----------------------------------------------------------------
%%% Types
--type log() :: #{level:=level(),
- msg:={io:format(),[term()]} |
- {report,report()} |
- {string,unicode:chardata()},
- meta:=metadata()}.
+-type log_event() :: #{level:=level(),
+ msg:={io:format(),[term()]} |
+ {report,report()} |
+ {string,unicode:chardata()},
+ meta:=metadata()}.
-type level() :: emergency | alert | critical | error |
warning | notice | info | debug.
-type report() :: map() | [{atom(),term()}].
@@ -87,9 +87,10 @@
line := non_neg_integer()}.
-type handler_id() :: atom().
-type filter_id() :: atom().
--type filter() :: {fun((log(),filter_arg()) -> filter_return()),filter_arg()}.
+-type filter() :: {fun((log_event(),filter_arg()) ->
+ filter_return()),filter_arg()}.
-type filter_arg() :: term().
--type filter_return() :: stop | ignore | log().
+-type filter_return() :: stop | ignore | log_event().
-type config() :: #{id => handler_id(),
level => level(),
filter_default => log | stop,
@@ -101,9 +102,9 @@
-type config_handler() :: {handler, handler_id(), module(), config()}.
--export_type([log/0,level/0,report/0,msg_fun/0,metadata/0,config/0,handler_id/0,
- filter_id/0,filter/0,filter_arg/0,filter_return/0,config_handler/0,
- formatter_config/0]).
+-export_type([log_event/0,level/0,report/0,msg_fun/0,metadata/0,config/0,
+ handler_id/0,filter_id/0,filter/0,filter_arg/0,filter_return/0,
+ config_handler/0,formatter_config/0]).
%%%-----------------------------------------------------------------
%%% API
diff --git a/lib/kernel/src/logger_backend.erl b/lib/kernel/src/logger_backend.erl
index d9f5aa6faf..b3cf7d67dd 100644
--- a/lib/kernel/src/logger_backend.erl
+++ b/lib/kernel/src/logger_backend.erl
@@ -58,7 +58,7 @@ call_handlers(#{level:=Level}=Log,[Id|Handlers],Tid) ->
debug,
[{logger,removed_failing_handler},
{handler,{Id,Module}},
- {log,Log1},
+ {log_event,Log1},
{config,Config1},
{reason,{C,R,filter_stacktrace(S)}}]);
{error,{not_found,_}} ->
@@ -122,7 +122,7 @@ handle_filter_failed({Id,_}=Filter,Owner,Log,Reason) ->
[{logger,removed_failing_filter},
{filter,Filter},
{owner,Owner},
- {log,Log},
+ {log_event,Log},
{reason,Reason}]);
_ ->
ok
diff --git a/lib/kernel/src/logger_disk_log_h.erl b/lib/kernel/src/logger_disk_log_h.erl
index 37a147e3dc..773aa75bc6 100644
--- a/lib/kernel/src/logger_disk_log_h.erl
+++ b/lib/kernel/src/logger_disk_log_h.erl
@@ -235,15 +235,15 @@ swap_buffer(Name,Buffer) ->
%%%-----------------------------------------------------------------
%%% Log a string or report
--spec log(Log, Config) -> ok | dropped when
- Log :: logger:log(),
+-spec log(LogEvent, Config) -> ok | dropped when
+ LogEvent :: logger:log_event(),
Config :: logger:config().
-log(Log,Config=#{id:=Name}) ->
+log(LogEvent,Config=#{id:=Name}) ->
%% if the handler has crashed, we must drop this request
%% and hope the handler restarts so we can try again
true = is_pid(whereis(Name)),
- Bin = logger_h_common:log_to_binary(Log,Config),
+ Bin = logger_h_common:log_to_binary(LogEvent,Config),
logger_h_common:call_cast_or_drop(Name, Bin).
diff --git a/lib/kernel/src/logger_filters.erl b/lib/kernel/src/logger_filters.erl
index 322aa0265d..7359b3b4b7 100644
--- a/lib/kernel/src/logger_filters.erl
+++ b/lib/kernel/src/logger_filters.erl
@@ -27,13 +27,13 @@
-include("logger_internal.hrl").
-define(IS_ACTION(A), (A==log orelse A==stop)).
--spec domain(Log,Extra) -> logger:filter_return() when
- Log :: logger:log(),
+-spec domain(LogEvent,Extra) -> logger:filter_return() when
+ LogEvent :: logger:log_event(),
Extra :: {Action,Compare,MatchDomain},
Action :: log | stop,
Compare :: super | sub | equal | not_equal | undefined,
MatchDomain :: list(atom()).
-domain(#{meta:=Meta}=Log,{Action,Compare,MatchDomain})
+domain(#{meta:=Meta}=LogEvent,{Action,Compare,MatchDomain})
when ?IS_ACTION(Action) andalso
(Compare==super orelse
Compare==sub orelse
@@ -41,17 +41,17 @@ domain(#{meta:=Meta}=Log,{Action,Compare,MatchDomain})
Compare==not_equal orelse
Compare==undefined) andalso
is_list(MatchDomain) ->
- filter_domain(Compare,Meta,MatchDomain,on_match(Action,Log));
-domain(Log,Extra) ->
- erlang:error(badarg,[Log,Extra]).
+ filter_domain(Compare,Meta,MatchDomain,on_match(Action,LogEvent));
+domain(LogEvent,Extra) ->
+ erlang:error(badarg,[LogEvent,Extra]).
--spec level(Log,Extra) -> logger:filter_return() when
- Log :: logger:log(),
+-spec level(LogEvent,Extra) -> logger:filter_return() when
+ LogEvent :: logger:log_event(),
Extra :: {Action,Operator,MatchLevel},
Action :: log | stop,
Operator :: neq | eq | lt | gt | lteq | gteq,
MatchLevel :: logger:level().
-level(#{level:=L1}=Log,{Action,Op,L2})
+level(#{level:=L1}=LogEvent,{Action,Op,L2})
when ?IS_ACTION(Action) andalso
(Op==neq orelse
Op==eq orelse
@@ -60,25 +60,25 @@ level(#{level:=L1}=Log,{Action,Op,L2})
Op==lteq orelse
Op==gteq) andalso
?IS_LEVEL(L2) ->
- filter_level(Op,L1,L2,on_match(Action,Log));
-level(Log,Extra) ->
- erlang:error(badarg,[Log,Extra]).
+ filter_level(Op,L1,L2,on_match(Action,LogEvent));
+level(LogEvent,Extra) ->
+ erlang:error(badarg,[LogEvent,Extra]).
--spec progress(Log,Extra) -> logger:filter_return() when
- Log :: logger:log(),
+-spec progress(LogEvent,Extra) -> logger:filter_return() when
+ LogEvent :: logger:log_event(),
Extra :: log | stop.
-progress(Log,Action) when ?IS_ACTION(Action) ->
- filter_progress(Log,on_match(Action,Log));
-progress(Log,Action) ->
- erlang:error(badarg,[Log,Action]).
+progress(LogEvent,Action) when ?IS_ACTION(Action) ->
+ filter_progress(LogEvent,on_match(Action,LogEvent));
+progress(LogEvent,Action) ->
+ erlang:error(badarg,[LogEvent,Action]).
--spec remote_gl(Log,Extra) -> logger:filter_return() when
- Log :: logger:log(),
+-spec remote_gl(LogEvent,Extra) -> logger:filter_return() when
+ LogEvent :: logger:log_event(),
Extra :: log | stop.
-remote_gl(Log,Action) when ?IS_ACTION(Action) ->
- filter_remote_gl(Log,on_match(Action,Log));
-remote_gl(Log,Action) ->
- erlang:error(badarg,[Log,Action]).
+remote_gl(LogEvent,Action) when ?IS_ACTION(Action) ->
+ filter_remote_gl(LogEvent,on_match(Action,LogEvent));
+remote_gl(LogEvent,Action) ->
+ erlang:error(badarg,[LogEvent,Action]).
%%%-----------------------------------------------------------------
%%% Internal
@@ -123,5 +123,5 @@ filter_remote_gl(#{meta:=#{gl:=GL}},OnMatch) when node(GL)=/=node() ->
filter_remote_gl(_,_) ->
ignore.
-on_match(log,Log) -> Log;
+on_match(log,LogEvent) -> LogEvent;
on_match(stop,_) -> stop.
diff --git a/lib/kernel/src/logger_formatter.erl b/lib/kernel/src/logger_formatter.erl
index 5882c70ddf..95cb6e35fc 100644
--- a/lib/kernel/src/logger_formatter.erl
+++ b/lib/kernel/src/logger_formatter.erl
@@ -30,8 +30,8 @@
%%%-----------------------------------------------------------------
%%% API
--spec format(Log,Config) -> unicode:chardata() when
- Log :: logger:log(),
+-spec format(LogEvent,Config) -> unicode:chardata() when
+ LogEvent :: logger:log_event(),
Config :: #{single_line=>boolean(),
legacy_header=>boolean(),
report_cb=>fun((logger:report()) -> {io:format(),[term()]}),
diff --git a/lib/kernel/src/logger_h_common.erl b/lib/kernel/src/logger_h_common.erl
index 70531c0e34..336398cd4a 100644
--- a/lib/kernel/src/logger_h_common.erl
+++ b/lib/kernel/src/logger_h_common.erl
@@ -39,8 +39,8 @@
%%%-----------------------------------------------------------------
%%% Covert log data on any form to binary
--spec log_to_binary(Log,Config) -> LogString when
- Log :: logger:log(),
+-spec log_to_binary(LogEvent,Config) -> LogString when
+ LogEvent :: logger:log_event(),
Config :: logger:config(),
LogString :: binary().
log_to_binary(#{msg:={report,_},meta:=#{report_cb:=_}}=Log,Config) ->
@@ -58,7 +58,7 @@ do_log_to_binary(Log,Config) ->
catch _:_ ->
?LOG_INTERNAL(debug,[{formatter_error,Formatter},
{config,FormatterConfig},
- {log,Log},
+ {log_event,Log},
{bad_return_value,String}]),
<<"FORMATTER ERROR: bad_return_value">>
end.
@@ -69,7 +69,7 @@ try_format(Log,Formatter,FormatterConfig) ->
C:R:S ->
?LOG_INTERNAL(debug,[{formatter_crashed,Formatter},
{config,FormatterConfig},
- {log,Log},
+ {log_event,Log},
{reason,
{C,R,logger:filter_stacktrace(?MODULE,S)}}]),
case {?DEFAULT_FORMATTER,#{}} of
diff --git a/lib/kernel/src/logger_std_h.erl b/lib/kernel/src/logger_std_h.erl
index fc8ca1535b..63c3ab2dac 100644
--- a/lib/kernel/src/logger_std_h.erl
+++ b/lib/kernel/src/logger_std_h.erl
@@ -219,15 +219,15 @@ swap_buffer(Name,Buffer) ->
%%%-----------------------------------------------------------------
%%% Log a string or report
--spec log(Log, Config) -> ok | dropped when
- Log :: logger:log(),
+-spec log(LogEvent, Config) -> ok | dropped when
+ LogEvent :: logger:log_event(),
Config :: logger:config().
-log(Log,Config=#{id:=Name}) ->
+log(LogEvent,Config=#{id:=Name}) ->
%% if the handler has crashed, we must drop this request
%% and hope the handler restarts so we can try again
true = is_pid(whereis(Name)),
- Bin = logger_h_common:log_to_binary(Log,Config),
+ Bin = logger_h_common:log_to_binary(LogEvent,Config),
logger_h_common:call_cast_or_drop(Name, Bin).
%%%===================================================================
diff --git a/lib/kernel/test/logger_formatter_SUITE.erl b/lib/kernel/test/logger_formatter_SUITE.erl
index eaa6c0aca5..7a93f2ca79 100644
--- a/lib/kernel/test/logger_formatter_SUITE.erl
+++ b/lib/kernel/test/logger_formatter_SUITE.erl
@@ -514,7 +514,7 @@ level_or_msg_in_meta(_Config) ->
ok.
faulty_log(_Config) ->
- %% Unexpected log (should be type logger:log()) - print error
+ %% Unexpected log (should be type logger:log_event()) - print error
{error,
function_clause,
{logger_formatter,format,[_,_],_}} =