Parcourir la source

ft:修改

master
SisMaker il y a 4 ans
Parent
révision
21bdb323d9
21 fichiers modifiés avec 82 ajouts et 78 suppressions
  1. +0
    -0
      include/eRum.hrl
  2. +1
    -0
      rebar.config
  3. +1
    -1
      src/backend/rumBackendConsole.erl
  4. +1
    -1
      src/backend/rumBackendFile.erl
  5. +1
    -1
      src/backend/rumBackendThrottle.erl
  6. +1
    -1
      src/eRum.erl
  7. +1
    -1
      src/eRum_app.erl
  8. +1
    -1
      src/formatter/rumFormatter.erl
  9. +1
    -1
      src/misc/rumConfig.erl
  10. +1
    -1
      src/misc/rumCrashLog.erl
  11. +1
    -1
      src/misc/rumErrLoggerH.erl
  12. +1
    -1
      src/misc/rumMgrKiller.erl
  13. +1
    -1
      src/misc/rumUtil.erl
  14. +1
    -1
      src/test/lager_common_test_backend.erl
  15. +1
    -1
      src/transform/rumTransform.erl
  16. +28
    -49
      src/watcher/rumHleWatcherSrv.erl
  17. +36
    -12
      src/watcher/rumHleWatcherSup.erl
  18. +1
    -1
      test/lager_crash_backend.erl
  19. +1
    -1
      test/lager_slow_backend.erl
  20. +1
    -1
      test/lager_test_backend.erl
  21. +1
    -1
      test/lager_test_function_transform.erl

include/rum.hrl → include/eRum.hrl Voir le fichier


+ 1
- 0
rebar.config Voir le fichier

@ -29,6 +29,7 @@
]}.
{deps, [
{eGbh, ".*", {git, "http://192.168.0.88:53000/SisMaker/eGbh.git", {branch, "master"}}},
{goldrush, "0.1.9"}
]}.

+ 1
- 1
src/backend/rumBackendConsole.erl Voir le fichier

@ -30,7 +30,7 @@
-endif.
-include("rum.hrl").
-include("eRum.hrl").
-define(TERSE_FORMAT, [time, " ", color, "[", severity, "] ", message]).
-define(DEFAULT_FORMAT_CONFIG, ?TERSE_FORMAT ++ [eol()]).

+ 1
- 1
src/backend/rumBackendFile.erl Voir le fichier

@ -14,7 +14,7 @@
-module(rumBackendFile).
-include("rum.hrl").
-include("eRum.hrl").
-include_lib("kernel/include/file.hrl").
-behaviour(gen_event).

+ 1
- 1
src/backend/rumBackendThrottle.erl Voir le fichier

@ -8,7 +8,7 @@
-behaviour(gen_event).
-include("rum.hrl").
-include("eRum.hrl").
-export([
init/1

+ 1
- 1
src/eRum.erl Voir le fichier

@ -18,7 +18,7 @@
-module(eRum).
-include("rum.hrl").
-include("eRum.hrl").
-define(LAGER_MD_KEY, '__lager_metadata').
-define(TRACE_SINK, '__trace_sink').

+ 1
- 1
src/eRum_app.erl Voir le fichier

@ -2,7 +2,7 @@
-behaviour(application).
-include("rum.hrl").
-include("eRum.hrl").
-export([
start/0

+ 1
- 1
src/formatter/rumFormatter.erl Voir le fichier

@ -19,7 +19,7 @@
%%
%% Include files
%%
-include("rum.hrl").
-include("eRum.hrl").
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.

+ 1
- 1
src/misc/rumConfig.erl Voir le fichier

@ -1,6 +1,6 @@
-module(rumConfig).
-include("rum.hrl").
-include("eRum.hrl").
-export([
new/0

+ 1
- 1
src/misc/rumCrashLog.erl Voir le fichier

@ -33,7 +33,7 @@
-module(rumCrashLog).
-include("rum.hrl").
-include("eRum.hrl").
-behaviour(gen_server).

+ 1
- 1
src/misc/rumErrLoggerH.erl Voir le fichier

@ -23,7 +23,7 @@
-module(rumErrLoggerH).
-include("rum.hrl").
-include("eRum.hrl").
-behaviour(gen_event).

+ 1
- 1
src/misc/rumMgrKiller.erl Voir le fichier

@ -6,7 +6,7 @@
-export([kill_me/0]).
-include("rum.hrl").
-include("eRum.hrl").
-record(state, {
killer_hwm :: non_neg_integer(),

+ 1
- 1
src/misc/rumUtil.erl Voir le fichier

@ -38,7 +38,7 @@
-include_lib("eunit/include/eunit.hrl").
-endif.
-include("rum.hrl").
-include("eRum.hrl").
-include_lib("kernel/include/file.hrl").

+ 1
- 1
src/test/lager_common_test_backend.erl Voir le fichier

@ -19,7 +19,7 @@
format_config :: any(),
log = [] :: list()}).
-include("rum.hrl").
-include("eRum.hrl").
-define(TERSE_FORMAT, [time, " ", color, "[", severity, "] ", message]).
%% @doc Before every test, just

+ 1
- 1
src/transform/rumTransform.erl Voir le fichier

@ -1,6 +1,6 @@
-module(rumTransform).
-include("rum.hrl").
-include("eRum.hrl").
-export([parse_transform/2]).

+ 28
- 49
src/watcher/rumHleWatcherSrv.erl Voir le fichier

@ -1,40 +1,22 @@
%% Copyright (c) 2011-2012 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%% @doc A process that does a gen_event:add_sup_handler and attempts to re-add
%% event handlers when they exit.
%% @private
-module(rumHleWatcherSrv).
-behaviour(gen_server).
-include("rum.hrl").
-behaviour(gen_srv).
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-export([pop_until/2]).
-endif.
-include("eRum.hrl").
%% callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
code_change/3]).
-export([
start/3
, start_link/3
]).
-export([start_link/3, start/3]).
-export([
init/1
, handleCall/3
, handleCast/2
, handleInfo/2
, terminate/2,
code_change/3
]).
-record(state, {
module :: atom(),
@ -53,17 +35,17 @@ init([Sink, Module, Config]) ->
install_handler(Sink, Module, Config),
{ok, #state{sink = Sink, module = Module, config = Config}}.
handle_call(_Call, _From, State) ->
handleCall(_Call, State, _From) ->
{reply, ok, State}.
handle_cast(_Request, State) ->
handleCast(_Request, State) ->
{noreply, State}.
handle_info({gen_event_EXIT, Module, normal}, #state{module = Module} = State) ->
handleInfo({gen_event_EXIT, Module, normal}, #state{module = Module} = State) ->
{stop, normal, State};
handle_info({gen_event_EXIT, Module, shutdown}, #state{module = Module} = State) ->
handleInfo({gen_event_EXIT, Module, shutdown}, #state{module = Module} = State) ->
{stop, normal, State};
handle_info({gen_event_EXIT, Module, {'EXIT', {kill_me, [_KillerHWM, KillerReinstallAfter]}}},
handleInfo({gen_event_EXIT, Module, {'EXIT', {kill_me, [_KillerHWM, KillerReinstallAfter]}}},
#state{module = Module, sink = Sink, config = Config} = State) ->
%% Brutally kill the manager but stay alive to restore settings.
%%
@ -77,10 +59,9 @@ handle_info({gen_event_EXIT, Module, {'EXIT', {kill_me, [_KillerHWM, KillerReins
exit(SinkPid, kill),
_ = timer:apply_after(KillerReinstallAfter, lager_app, start_handler, [Sink, Module, Config]),
{stop, normal, State};
handle_info({gen_event_EXIT, Module, Reason}, #state{module = Module,
handleInfo({gen_event_EXIT, Module, Reason}, #state{module = Module,
config = Config, sink = Sink} = State) ->
case eRum:log(error, self(), "Lager event handler ~p exited with reason ~s",
[Module, rumErrLoggerH:format_reason(Reason)]) of
case eRum:log(error, self(), "Lager event handler ~p exited with reason ~s", [Module, rumErrLoggerH:format_reason(Reason)]) of
ok ->
install_handler(Sink, Module, Config);
{error, _} ->
@ -88,19 +69,19 @@ handle_info({gen_event_EXIT, Module, Reason}, #state{module = Module,
ok
end,
{noreply, State};
handle_info(reinstall_handler, #state{module = Module, config = Config, sink = Sink} = State) ->
handleInfo(reinstall_handler, #state{module = Module, config = Config, sink = Sink} = State) ->
install_handler(Sink, Module, Config),
{noreply, State};
handle_info({reboot, Sink}, State) ->
handleInfo({reboot, Sink}, State) ->
_ = lager_app:boot(Sink),
{noreply, State};
handle_info(stop, State) ->
handleInfo(stop, State) ->
{stop, normal, State};
handle_info({'EXIT', _Pid, killed}, #state{module = Module, config = Config, sink = Sink} = State) ->
handleInfo({'EXIT', _Pid, killed}, #state{module = Module, config = Config, sink = Sink} = State) ->
Tmr = application:get_env(lager, killer_reinstall_after, 5000),
_ = timer:apply_after(Tmr, lager_app, start_handler, [Sink, Module, Config]),
{stop, normal, State};
handle_info(_Info, State) ->
handleInfo(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
@ -128,15 +109,13 @@ install_handler2(Sink, Module, Config) ->
eRum:update_loglevel_config(Sink),
ok;
{error, {fatal, Reason}} ->
?INT_LOG(error, "Lager fatally failed to install handler ~p into"
" ~p, NOT retrying: ~p", [Module, Sink, Reason]),
?INT_LOG(error, "Lager fatally failed to install handler ~p into ~p, NOT retrying: ~p", [Module, Sink, Reason]),
%% tell ourselves to stop
self() ! stop,
ok;
Error ->
%% try to reinstall it later
?INT_LOG(error, "Lager failed to install handler ~p into"
" ~p, retrying later : ~p", [Module, Sink, Error]),
?INT_LOG(error, "Lager failed to install handler ~p into ~p, retrying later : ~p", [Module, Sink, Error]),
erlang:send_after(5000, self(), reinstall_handler),
ok
end.

+ 36
- 12
src/watcher/rumHleWatcherSup.erl Voir le fichier

@ -1,23 +1,47 @@
%% @doc A supervisor for monitoring lager_handler_watcher processes.
%% @private
-module(rumHleWatcherSup).
-behaviour(supervisor).
%% API
-export([start_link/0]).
-export([
start_link/0
]).
%% Callbacks
-export([init/1]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
%
% sup_flags() =
% #{
% strategy => strategy(), % optional one_for_one | one_for_all | rest_for_one | simple_one_for_one
% intensity => non_neg_integer(), % optional MaxR
% period => pos_integer() % optional MaxT MaxT里重启次数大于MaxR
% }
% child_spec() =
% #{
% id => child_id(), % mandatory Id用来内部标识子规范
% start => mfargs(), % mandatory {MFA}
% restart => restart(), % optional permanent() | transient( normal,shutdown,{shutdown,Term}) | temporary()
% shutdown => shutdown(), % optional brutal_kill | infinity | integer
% type => worker(), % optional supervisor | worker
% modules => modules() % optional [Module] supervisorgen_server gen_fsmModule gen_eventModules dynamic
% }
init([]) ->
{ok, {{simple_one_for_one, 10, 60},
[
{lager_handler_watcher, {lager_handler_watcher, start_link, []},
temporary, 5000, worker, [lager_handler_watcher]}
]}}.
SupFlags =
#{
strategy => simple_one_for_one,
intensity => 10,
period => 60
},
ChildSpecs = [
#{
id => rumHleWatcherSrv,
start => {rumHleWatcherSrv, start_link, []},
restart => temporary,
shutdown => 5000,
type => worker,
modules => [rumHleWatcherSrv]
}
],
{ok, {SupFlags, ChildSpecs}}.

+ 1
- 1
test/lager_crash_backend.erl Voir le fichier

@ -16,7 +16,7 @@
-module(lager_crash_backend).
-include("rum.hrl").
-include("eRum.hrl").
-behaviour(gen_event).

+ 1
- 1
test/lager_slow_backend.erl Voir le fichier

@ -4,7 +4,7 @@
-export([init/1, handle_call/2, handle_event/2, handle_info/2, terminate/2, code_change/3]).
-include("rum.hrl").
-include("eRum.hrl").
-record(state, {
delay :: non_neg_integer()

+ 1
- 1
test/lager_test_backend.erl Voir le fichier

@ -25,7 +25,7 @@
-export([init/1, handle_call/2, handle_event/2, handle_info/2, terminate/2,
code_change/3]).
-include("rum.hrl").
-include("eRum.hrl").
-define(TEST_SINK_NAME, '__lager_test_sink'). %% <-- used by parse transform
-define(TEST_SINK_EVENT, '__lager_test_sink_lager_event'). %% <-- used by lager API calls and internals for gen_event

+ 1
- 1
test/lager_test_function_transform.erl Voir le fichier

@ -20,7 +20,7 @@
-module(lager_test_function_transform).
-include("rum.hrl").
-include("eRum.hrl").
-compile([{nowarn_deprecated_function, [{erlang, now, 0}]}]).

Chargement…
Annuler
Enregistrer