Use lager for all log messages

This commit is contained in:
Gregory Burd 2011-11-30 14:44:39 -05:00
parent 7fc539984f
commit 72cf45ff3f
7 changed files with 32 additions and 17 deletions

1
.gitignore vendored
View file

@ -5,6 +5,7 @@
*.so
*.beam
*.orig
deps
logs
doc
include/BDBERL-MIB.hrl

View file

@ -4,13 +4,19 @@ CT_RUN ?=ct_run
ERL_FLAGS ?=+A10
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
test: tests
tests:
@ $(REBAR) $(REBAR_FLAGS) eunit ct
@ $(REBAR) $(REBAR_FLAGS) eunit app=bdberl
@ $(REBAR) $(REBAR_FLAGS) ct app=bdberl
thrash-test:
@ $(CT_RUN) -pa test/ -suite thrash_SUITE
@ -20,6 +26,7 @@ clean:
-rm test/*.beam
distclean: clean
$(REBAR) delete-deps
-make -C c_src clean
-rm -rf c_src/sources
-rm -rf priv

View file

@ -2,6 +2,6 @@
[{description,"This is an Erlang port driver that allows Erlang programs to store data in BerkleyDB."},
{vsn,"5.2.28"},
{registered,[]},
{applications,[kernel,stdlib]},
{applications,[kernel,stdlib,lager]},
{env,[]},
{modules,[bdberl,bdberl_logger]}]}.

View file

@ -4,8 +4,14 @@
%% ex: ft=erlang ts=4 sw=4 et
%%
{require_otp_vsn, "R13B04|R14"}.
{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, [
{"DRV_CFLAGS", "$DRV_CFLAGS -Werror -I c_src/system/include"},

View file

@ -5,7 +5,8 @@
{registered, []},
{applications, [
kernel,
stdlib
stdlib,
lager
]},
{env, []}
]}.
]}.

View file

@ -571,7 +571,7 @@ transaction(Fun, Retries, TimeLeft, Opts) ->
ok ->
try Fun() of
abort ->
error_logger:info_msg("function requested abort"),
lager:info("function requested abort"),
ok = txn_abort(),
{error, transaction_aborted};
@ -595,7 +595,7 @@ transaction(Fun, Retries, TimeLeft, Opts) ->
transaction(Fun, R, T, Opts);
_ : Reason ->
error_logger:info_msg("function threw non-lock error - ~p", [Reason]),
lager:info("function threw non-lock error - ~p", [Reason]),
ok = txn_abort(),
{error, {transaction_failed, Reason}}
end;
@ -900,7 +900,7 @@ get(Db, Key, Opts) ->
Crc ->
{ok, binary_to_term(Payload)};
CrcOther ->
error_logger:warning_msg("Invalid CRC: ~p ~p\n", [Crc, CrcOther]),
lager:warning("Invalid CRC: ~p ~p\n", [Crc, CrcOther]),
{error, invalid_crc}
end;
not_found -> not_found;
@ -1386,7 +1386,7 @@ cursor_get(Key, Opts) ->
Crc ->
{ok, binary_to_term(Payload)};
CrcOther ->
error_logger:warning_msg("Invalid CRC: ~p ~p\n", [Crc, CrcOther]),
lager:warning("Invalid CRC: ~p ~p\n", [Crc, CrcOther]),
{error, invalid_crc}
end;
not_found -> not_found;
@ -2439,7 +2439,7 @@ do_cursor_move(Direction) ->
Crc ->
{ok, binary_to_term(KeyBin), binary_to_term(Payload)};
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}
end;
not_found ->

View file

@ -67,9 +67,9 @@ init([]) ->
true ->
load_mibs(['BDBERL-MIB']);
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,
{ok, #state{}}.
handle_call(_Request, _From, State) ->
@ -79,11 +79,11 @@ handle_cast(_Msg, State) ->
{stop, unsupportedOperation, 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};
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};
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};
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};
handle_info({bdb_trickle_stats, ElapsedSecs, Pages, 0}, State) ->
@ -112,7 +112,7 @@ handle_info({bdb_trickle_stats, ElapsedSecs, Pages, 0}, State) ->
end,
{noreply, 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};
handle_info(Msg, State) ->