Use lager for all log messages
This commit is contained in:
parent
7fc539984f
commit
72cf45ff3f
7 changed files with 32 additions and 17 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,6 +5,7 @@
|
||||||
*.so
|
*.so
|
||||||
*.beam
|
*.beam
|
||||||
*.orig
|
*.orig
|
||||||
|
deps
|
||||||
logs
|
logs
|
||||||
doc
|
doc
|
||||||
include/BDBERL-MIB.hrl
|
include/BDBERL-MIB.hrl
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -4,13 +4,19 @@ CT_RUN ?=ct_run
|
||||||
ERL_FLAGS ?=+A10
|
ERL_FLAGS ?=+A10
|
||||||
REBAR_FLAGS :=
|
REBAR_FLAGS :=
|
||||||
|
|
||||||
all: $(BDB_LOCAL_LIB)
|
all: deps compile
|
||||||
|
|
||||||
|
deps:
|
||||||
|
$(REBAR) get-deps
|
||||||
|
|
||||||
|
compile: $(BDB_LOCAL_LIB)
|
||||||
ERL_FLAGS=$(ERL_FLAGS) $(REBAR) $(REBAR_FLAGS) compile
|
ERL_FLAGS=$(ERL_FLAGS) $(REBAR) $(REBAR_FLAGS) compile
|
||||||
|
|
||||||
test: tests
|
test: tests
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
@ $(REBAR) $(REBAR_FLAGS) eunit ct
|
@ $(REBAR) $(REBAR_FLAGS) eunit app=bdberl
|
||||||
|
@ $(REBAR) $(REBAR_FLAGS) ct app=bdberl
|
||||||
|
|
||||||
thrash-test:
|
thrash-test:
|
||||||
@ $(CT_RUN) -pa test/ -suite thrash_SUITE
|
@ $(CT_RUN) -pa test/ -suite thrash_SUITE
|
||||||
|
@ -20,6 +26,7 @@ clean:
|
||||||
-rm test/*.beam
|
-rm test/*.beam
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
|
$(REBAR) delete-deps
|
||||||
-make -C c_src clean
|
-make -C c_src clean
|
||||||
-rm -rf c_src/sources
|
-rm -rf c_src/sources
|
||||||
-rm -rf priv
|
-rm -rf priv
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
[{description,"This is an Erlang port driver that allows Erlang programs to store data in BerkleyDB."},
|
[{description,"This is an Erlang port driver that allows Erlang programs to store data in BerkleyDB."},
|
||||||
{vsn,"5.2.28"},
|
{vsn,"5.2.28"},
|
||||||
{registered,[]},
|
{registered,[]},
|
||||||
{applications,[kernel,stdlib]},
|
{applications,[kernel,stdlib,lager]},
|
||||||
{env,[]},
|
{env,[]},
|
||||||
{modules,[bdberl,bdberl_logger]}]}.
|
{modules,[bdberl,bdberl_logger]}]}.
|
||||||
|
|
|
@ -4,8 +4,14 @@
|
||||||
%% ex: ft=erlang ts=4 sw=4 et
|
%% ex: ft=erlang ts=4 sw=4 et
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
{require_otp_vsn, "R13B04|R14"}.
|
||||||
{cover_enabled, true}.
|
{cover_enabled, true}.
|
||||||
{erl_opts, [warnings_as_errors]}.
|
|
||||||
|
{deps, [
|
||||||
|
{lager, ".*", {git, "git://github.com/basho/lager", {branch, "master"}}}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{erl_opts, [warnings_as_errors, {parse_transform, lager_transform}]}.
|
||||||
|
|
||||||
{port_envs, [
|
{port_envs, [
|
||||||
{"DRV_CFLAGS", "$DRV_CFLAGS -Werror -I c_src/system/include"},
|
{"DRV_CFLAGS", "$DRV_CFLAGS -Werror -I c_src/system/include"},
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [
|
{applications, [
|
||||||
kernel,
|
kernel,
|
||||||
stdlib
|
stdlib,
|
||||||
|
lager
|
||||||
]},
|
]},
|
||||||
{env, []}
|
{env, []}
|
||||||
]}.
|
]}.
|
||||||
|
|
|
@ -571,7 +571,7 @@ transaction(Fun, Retries, TimeLeft, Opts) ->
|
||||||
ok ->
|
ok ->
|
||||||
try Fun() of
|
try Fun() of
|
||||||
abort ->
|
abort ->
|
||||||
error_logger:info_msg("function requested abort"),
|
lager:info("function requested abort"),
|
||||||
ok = txn_abort(),
|
ok = txn_abort(),
|
||||||
{error, transaction_aborted};
|
{error, transaction_aborted};
|
||||||
|
|
||||||
|
@ -595,7 +595,7 @@ transaction(Fun, Retries, TimeLeft, Opts) ->
|
||||||
transaction(Fun, R, T, Opts);
|
transaction(Fun, R, T, Opts);
|
||||||
|
|
||||||
_ : Reason ->
|
_ : Reason ->
|
||||||
error_logger:info_msg("function threw non-lock error - ~p", [Reason]),
|
lager:info("function threw non-lock error - ~p", [Reason]),
|
||||||
ok = txn_abort(),
|
ok = txn_abort(),
|
||||||
{error, {transaction_failed, Reason}}
|
{error, {transaction_failed, Reason}}
|
||||||
end;
|
end;
|
||||||
|
@ -900,7 +900,7 @@ get(Db, Key, Opts) ->
|
||||||
Crc ->
|
Crc ->
|
||||||
{ok, binary_to_term(Payload)};
|
{ok, binary_to_term(Payload)};
|
||||||
CrcOther ->
|
CrcOther ->
|
||||||
error_logger:warning_msg("Invalid CRC: ~p ~p\n", [Crc, CrcOther]),
|
lager:warning("Invalid CRC: ~p ~p\n", [Crc, CrcOther]),
|
||||||
{error, invalid_crc}
|
{error, invalid_crc}
|
||||||
end;
|
end;
|
||||||
not_found -> not_found;
|
not_found -> not_found;
|
||||||
|
@ -1386,7 +1386,7 @@ cursor_get(Key, Opts) ->
|
||||||
Crc ->
|
Crc ->
|
||||||
{ok, binary_to_term(Payload)};
|
{ok, binary_to_term(Payload)};
|
||||||
CrcOther ->
|
CrcOther ->
|
||||||
error_logger:warning_msg("Invalid CRC: ~p ~p\n", [Crc, CrcOther]),
|
lager:warning("Invalid CRC: ~p ~p\n", [Crc, CrcOther]),
|
||||||
{error, invalid_crc}
|
{error, invalid_crc}
|
||||||
end;
|
end;
|
||||||
not_found -> not_found;
|
not_found -> not_found;
|
||||||
|
@ -2439,7 +2439,7 @@ do_cursor_move(Direction) ->
|
||||||
Crc ->
|
Crc ->
|
||||||
{ok, binary_to_term(KeyBin), binary_to_term(Payload)};
|
{ok, binary_to_term(KeyBin), binary_to_term(Payload)};
|
||||||
CrcOther ->
|
CrcOther ->
|
||||||
error_logger:warning_msg("Invalid CRC on cursor: ~p ~p\n", [Crc, CrcOther]),
|
lager:warning("Invalid CRC on cursor: ~p ~p\n", [Crc, CrcOther]),
|
||||||
{error, invalid_crc}
|
{error, invalid_crc}
|
||||||
end;
|
end;
|
||||||
not_found ->
|
not_found ->
|
||||||
|
|
|
@ -67,9 +67,9 @@ init([]) ->
|
||||||
true ->
|
true ->
|
||||||
load_mibs(['BDBERL-MIB']);
|
load_mibs(['BDBERL-MIB']);
|
||||||
false ->
|
false ->
|
||||||
error_logger:warning_msg("SNMP is not running; bdberl stats will not be published.\n")
|
lager:warning("SNMP is not running; bdberl stats will not be published.\n")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
{ok, #state{}}.
|
{ok, #state{}}.
|
||||||
|
|
||||||
handle_call(_Request, _From, State) ->
|
handle_call(_Request, _From, State) ->
|
||||||
|
@ -79,11 +79,11 @@ handle_cast(_Msg, State) ->
|
||||||
{stop, unsupportedOperation, State}.
|
{stop, unsupportedOperation, State}.
|
||||||
|
|
||||||
handle_info({bdb_error_log, Msg}, State) ->
|
handle_info({bdb_error_log, Msg}, State) ->
|
||||||
error_logger:error_msg("BDB Error: ~s\n", [Msg]),
|
lager:error("BDB Error: ~s\n", [Msg]),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_info({bdb_info_log, Msg}, State) ->
|
handle_info({bdb_info_log, Msg}, State) ->
|
||||||
error_logger:info_msg("BDB Info: ~s\n", [Msg]),
|
lager:info("BDB Info: ~s\n", [Msg]),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_info({bdb_checkpoint_stats, CheckpointSecs, ArchiveSecs, 0, 0}, State) ->
|
handle_info({bdb_checkpoint_stats, CheckpointSecs, ArchiveSecs, 0, 0}, State) ->
|
||||||
|
@ -98,7 +98,7 @@ handle_info({bdb_checkpoint_stats, CheckpointSecs, ArchiveSecs, 0, 0}, State) ->
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_info({bdb_checkpoint_stats, _CheckpointSecs, _ArchiveSecs, CheckpointRc, ArchiveRc}, State) ->
|
handle_info({bdb_checkpoint_stats, _CheckpointSecs, _ArchiveSecs, CheckpointRc, ArchiveRc}, State) ->
|
||||||
error_logger:error_msg("BDB Checkpoint error: ~w ~w\n", [CheckpointRc, ArchiveRc]),
|
lager:error("BDB Checkpoint error: ~w ~w\n", [CheckpointRc, ArchiveRc]),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_info({bdb_trickle_stats, ElapsedSecs, Pages, 0}, State) ->
|
handle_info({bdb_trickle_stats, ElapsedSecs, Pages, 0}, State) ->
|
||||||
|
@ -112,7 +112,7 @@ handle_info({bdb_trickle_stats, ElapsedSecs, Pages, 0}, State) ->
|
||||||
end,
|
end,
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_info({bdb_trickle_stats, _ElapsedSecs, _Pages, Rc}, State) ->
|
handle_info({bdb_trickle_stats, _ElapsedSecs, _Pages, Rc}, State) ->
|
||||||
error_logger:error_msg("BDB Trickle Write error: ~w\n", [Rc]),
|
lager:error("BDB Trickle Write error: ~w\n", [Rc]),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_info(Msg, State) ->
|
handle_info(Msg, State) ->
|
||||||
|
|
Loading…
Reference in a new issue