瀏覽代碼

ft: rumMsg相关整理

master
SisMaker 4 年之前
父節點
當前提交
d3055f3720
共有 7 個檔案被更改,包括 30 行新增36 行删除
  1. +6
    -6
      README.md
  2. +8
    -14
      eRum.sample.config
  3. +2
    -2
      src/eRum.erl
  4. +2
    -2
      src/eRum1.erl
  5. +3
    -3
      src/eRum_app.erl
  6. +6
    -6
      src/errLogger/rumErrLoggerH.erl
  7. +3
    -3
      进度.md

+ 6
- 6
README.md 查看文件

@ -96,7 +96,7 @@ To be useful, sinks must be configured at runtime with backends.
In `app.config` for the project that requires lager, for example, extend the lager configuration to include
an `extraSinks` tuple with backends (aka "handlers") and optionally `asyncThreshold` and
`asyncThresholdWindow` values (see **Overload Protection**
`asyncThrWindow` values (see **Overload Protection**
below). If async values are not configured, no overload protection will be applied on that sink.
```erlang
@ -114,7 +114,7 @@ below). If async values are not configured, no overload protection will be appli
{audit_lager_event,
[{handlers, [{lager_file_backend, [{file, "sink1.log"}, {level, info}]}]},
{asyncThreshold, 500},
{asyncThresholdWindow, 50}]
{asyncThrWindow, 50}]
}]}
]}].
```
@ -206,7 +206,7 @@ will send all `error_logger` messages to `error_logger.log` file.
```erlang
{asyncThreshold, 20},
{asyncThresholdWindow, 5}
{asyncThrWindow, 5}
```
这将使用异步消息传递,直到邮箱超过20条消息为止,此时将使用同步消息传递,并在大小减小为时切换回异步20 - 5 = 15。
@ -236,7 +236,7 @@ or for a specific sink, using the option:
如果flush_queue为true,则可以设置消息队列长度阈值,在该阈值处将开始丢弃消息。默认阈值为0,这意味着如果flush_queue为true,则超过高水位标记时将丢弃消息,而不管消息队列的长度如何。用于控制阈值的选项是error_logger:
```erlang
{errLoggerFlushThreshold, 1000}
{errLoggerFlushThr, 1000}
```
and for sinks:
@ -681,8 +681,8 @@ erlc -pa lager/ebin +'{parse_transform, lager_transform}' +'{lager_truncation_si
如果您不想在应用程序的调试级别看到主管和应用程序启动/停止日志,则可以使用以下配置将其关闭:
```erlang
{lager, [{suppress_application_start_stop, true},
{suppress_supervisor_start_stop, true}]}
{lager, [{suppressAppStartStop, true},
{suppressSupStartStop, true}]}
```
系统调试功能

+ 8
- 14
eRum.sample.config 查看文件

@ -17,15 +17,15 @@
%% ******************************************** format相关 ******************************************************
{metadataWhitelist, []},
{reverseRrettyStacktrace, true},
{rPrettyStrace, true},
%%*********************************************** 异步日志相关 *****************************************************
%% 异步切换到同步时模式gen_event邮箱的最大消息数,此值仅应用于默认接收器; 额外的接收器也可以自己配置。
%% 格式 integer() | undefined 当值为undefined 禁用此功能
{asyncThreshold, 20},
%%当gen_event 邮箱大小从 asyncThreshold 减小到 asyncThreshold-asyncThresholdWindow 时,切换回异步模式。
%%当gen_event 邮箱大小从 asyncThreshold 减小到 asyncThreshold-asyncThrWindow 时,切换回异步模式。
%% 此值仅适用于默认接收器。额外的接收器可以自己配置。
{asyncThresholdWindow, 5},
{asyncThrWindow, 5},
%%*********************************************** handler与接收器(sink) *****************************************
%% 消息处理模块可以存在多个,[{Name, [Optins]}]=Handler() {lager_file_backend, [{file, "console.log"}, {level, info}]} 消息处理模块可以存在多个
@ -53,7 +53,7 @@
%% 要保留的已轮转崩溃日志的数量,0表示仅保留当前的一个-默认值为0
{crashLogCount, 5},
%% 崩溃日志旋转器模块-默认为lager_rotator_default
{crashLogRotator, lager_rotator_default},
{crashLogRotator, rumRotatorIns},
%% ********************************************** error_logger相关 **********************************************
%% 是否将error_logger消息重定向到默认的lager_event接收器-默认为true
@ -63,14 +63,14 @@
%% 每秒允许来自error_logger的消息数量是多少 超过就丢弃掉
{errLoggerHwm, 50},
%% errLogger group leader策略 handle | ignore | mirror
{errLoggerGroupLeaderStrategy, handle},
{errLoggerGLS, handle},
{errLoggerFormatRaw, false},
%% 超过高水位标记时,可以将啤酒配置为刷新消息队列中的所有事件通知
{errLoggerFlushQueue, true},
%% 如果flush_queue为true,则可以设置消息队列长度阈值,在该阈值处将开始丢弃消息。默认阈值为0,这意味着如果flush_queue为true,
%% 则超过高水位标记时将丢弃消息,而不管消息队列的长度如何。用于控制阈值的选项是error_logger:
{errLoggerFlushThreshold, 20},
{errLoggerFlushThr, 20},
%% ********************************************** killer相关 ****************************************************
%% 如果接收器的邮箱大小超过1000条消息,请杀死整个接收器并在5000毫秒后重新加载它。如果需要,此行为也可以安装到其他水槽中。
@ -80,14 +80,8 @@
%% ********************************************** app启动停止监听相关 *********************************************
%% 如果您不想在应用程序的调试级别看到主管和应用程序启动/停止日志,则可以使用以下配置将其关闭:
{suppress_application_start_stop, true},
{suppress_supervisor_start_stop, true}
%% **********************************************其他备注 ********************************************************
%%Lager默认将消息截断为4096字节,您可以使用该{lager_truncation_size, X}选项进行更改。在钢筋中,您可以将其添加到 erl_opts:
%%{ erl_opts,[{ parse_transform,lager_transform },{ lager_truncation_size,1024 }]}。
%%erlc如果您愿意,也可以将其传递给,
%%erlc -pa lager/ebin +'{parse_transform, lager_transform}' +'{lager_truncation_size, 1024}' file.erl
{suppressAppStartStop, true},
{suppressSupStartStop, true}
]}
].

+ 2
- 2
src/eRum.erl 查看文件

@ -211,7 +211,7 @@ setLogHwm(Sink, Handler, Ident, Hwm) when is_integer(Hwm) ->
%% @doc Print stacktrace in human readable form
pr_stacktrace(Stacktrace) ->
Stacktrace1 =
case rumUtil:get_env(reversePrettyStacktrace, true) of
case rumUtil:get_env(rPrettyStrace, true) of
true ->
lists:reverse(Stacktrace);
_ ->
@ -229,7 +229,7 @@ pr_stacktrace_(Stacktrace) ->
Stacktrace).
pr_stacktrace(Stacktrace, {Class, Reason}) ->
case rumUtil:get_env(reversePrettyStacktrace, true) of
case rumUtil:get_env(rPrettyStrace, true) of
true ->
lists:flatten(
pr_stacktrace_(lists:reverse(Stacktrace)) ++ "\n" ++ io_lib:format("~s:~p", [Class, Reason]));

+ 2
- 2
src/eRum1.erl 查看文件

@ -231,7 +231,7 @@ setLogHwm(Sink, Handler, Ident, Hwm) when is_integer(Hwm) ->
%% @doc Print stacktrace in human readable form
pr_stacktrace(Stacktrace) ->
Stacktrace1 =
case rumUtil:get_env(reversePrettyStacktrace, true) of
case rumUtil:get_env(rPrettyStrace, true) of
true ->
lists:reverse(Stacktrace);
_ ->
@ -249,7 +249,7 @@ pr_stacktrace_(Stacktrace) ->
Stacktrace).
pr_stacktrace(Stacktrace, {Class, Reason}) ->
case rumUtil:get_env(reversePrettyStacktrace, true) of
case rumUtil:get_env(rPrettyStrace, true) of
true ->
lists:flatten(
pr_stacktrace_(lists:reverse(Stacktrace)) ++ "\n" ++ io_lib:format("~s:~p", [Class, Reason]));

+ 3
- 3
src/eRum_app.erl 查看文件

@ -26,7 +26,7 @@ start(_StartType, _StartArgs) ->
%% (sink)
doStart() ->
%%
tryStartAsyncMgr(rumUtil:get_env(asyncThreshold, undefined), rumUtil:get_env(asyncThresholdWindow, undefined), ?RumDefSink),
tryStartAsyncMgr(rumUtil:get_env(asyncThreshold, undefined), rumUtil:get_env(asyncThrWindow, undefined), ?RumDefSink),
%%killer
tryInstallKiller(rumUtil:get_env(killerHwm, undefined), rumUtil:get_env(killerReTime, undefined), ?RumDefSink),
@ -57,7 +57,7 @@ startSink(Sink, Opts) ->
type => worker,
modules => [dynamic]},
_ = supervisor:start_child(eRum_sup, SinkSpec),
tryStartAsyncMgr(proplists:get_value(asyncThreshold, Opts, undefined), proplists:get_value(asyncThresholdWindow, Opts, undefined), Sink),
tryStartAsyncMgr(proplists:get_value(asyncThreshold, Opts, undefined), proplists:get_value(asyncThrWindow, Opts, undefined), Sink),
tryInstallKiller(proplists:get_value(killerHwm, Opts, undefined), proplists:get_value(killerReTime, Opts, undefined), Sink),
tryStartHandlers(proplists:get_value(handlers, Opts, []), Sink),
eRum:updateLogevelCfg(Sink).
@ -161,7 +161,7 @@ tryStartErrLoggerHandler(_ErrLoggerRedirect, HWM, WhiteList) ->
%% capture which handlers we removed from error_logger so we can restore them when lager stops
%% error_logger中删除的处理程序便lager停止时恢复它们
OldHandlers =
case supervisor:start_child(rumHWatcherSup, [error_logger, rumErrLoggerH, [HWM, rumUtil:get_env(errLoggerGroupLeaderStrategy, handle)]]) of
case supervisor:start_child(rumHWatcherSup, [error_logger, rumErrLoggerH, [HWM, rumUtil:get_env(errLoggerGLS, handle)]]) of
{ok, _} ->
[begin error_logger:delete_report_handler(X), X end || X <- gen_event:which_handlers(error_logger) -- [rumErrLoggerH | WhiteList]];
{error, _} ->

+ 6
- 6
src/errLogger/rumErrLoggerH.erl 查看文件

@ -66,7 +66,7 @@ setHighWater(N) ->
-spec init(any()) -> {ok, #state{}}.
init([HighWaterMark, GlStrategy]) ->
Flush = rumUtil:get_env(errLoggerFlushQueue, true),
FlushThr = rumUtil:get_env(errLoggerFlushThreshold, 0),
FlushThr = rumUtil:get_env(errLoggerFlushThr, 0),
Shaper = #rumShaper{hwm = HighWaterMark, flushQueue = Flush, flushThr = FlushThr, filter = shaperFun(), id = ?MODULE},
Raw = rumUtil:get_env(errLoggerFormatRaw, false),
Sink = configSink(),
@ -79,8 +79,8 @@ handle_call(_Request, State) ->
{ok, unknown_call, State}.
shaperFun() ->
SupSS = rumUtil:get_env(suppress_supervisor_start_stop, false),
AppSS = rumUtil:get_env(suppress_application_start_stop, false),
SupSS = rumUtil:get_env(suppressSupStartStop, false),
AppSS = rumUtil:get_env(suppressAppStartStop, false),
if
SupSS andalso AppSS ->
fun suppress_supervisor_start_and_application_start/1;
@ -330,7 +330,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
Details = lists:sort(D),
case Details of
[{application, App}, {exited, Reason}, {type, _Type}] ->
case rumUtil:get_env(suppress_application_start_stop, false) of
case rumUtil:get_env(suppressAppStartStop, false) of
true when Reason == stopped ->
no_log;
_ ->
@ -347,7 +347,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
Details = lists:sort(D),
case Details of
[{application, App}, {started_at, Node}] ->
case rumUtil:get_env(suppress_application_start_stop, false) of
case rumUtil:get_env(suppressAppStartStop, false) of
true ->
no_log;
_ ->
@ -355,7 +355,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
[App, Node])
end;
[{started, Started}, {supervisor, Name}] ->
case rumUtil:get_env(suppress_supervisor_start_stop, false) of
case rumUtil:get_env(suppressSupStartStop, false) of
true ->
no_log;
_ ->

+ 3
- 3
进度.md 查看文件

@ -22,9 +22,9 @@
# TODO
rumBkdFile选项命名+默认值修改
eRum.sameple.config 命名 +默认值修改
rumTruncIo.erl 删掉掉
rumBkdFile 默认值修改
eRum.sameple.config 默认值修改
rumMsg.erl 删掉掉
io_lib:format 替换为 eFmt:formatBin
各个模块审查一下
reamde.me 整理

Loading…
取消
儲存