Skip to content

Commit

Permalink
Merge pull request #27 from travelping/move_to_error_logger
Browse files Browse the repository at this point in the history
Get rid of lager and move to error_logger
  • Loading branch information
0xAX authored Aug 8, 2016
2 parents e5c88f7 + b85a4f1 commit f09ac7c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 38 deletions.
5 changes: 1 addition & 4 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{deps, [
{hackney, ".*", {git, "git://github.com/benoitc/hackney.git", {branch, "master"}}},
%% lager dependency to override exometer's lager dependency, which does not compile on Erlang 19.
{lager, ".*", {git, "git://github.com/basho/lager.git", {tag, "3.2.1"}}},
{exometer_core, ".*", {git, "git://github.com/Feuerlabs/exometer_core.git", "5fdd9426713a3c26cae32f644a3120711b1cdb64"}}
{exometer_core, ".*", {git, "git://github.com/Feuerlabs/exometer_core.git", "master"}}
]}.
{erl_opts, [{parse_transform, lager_transform}]}.
1 change: 0 additions & 1 deletion src/exometer_influxdb.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
kernel,
stdlib,
hackney,
lager,
exometer_core
]},
{env, []}
Expand Down
4 changes: 1 addition & 3 deletions src/exometer_report_influxdb.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ exometer_init(Opts) ->
state()) -> callback_result().
exometer_report(_Metric, _DataPoint, _Extra, _Value,
#state{connection = undefined} = State) ->
?debug("InfluxDB reporter isn't connected and will reconnect."),
?info("InfluxDB reporter isn't connected and will reconnect."),
{ok, State};
exometer_report(Metric, DataPoint, _Extra, Value,
#state{metrics = Metrics} = State) ->
Expand Down Expand Up @@ -176,8 +176,6 @@ exometer_info({exometer_influxdb, send},
#state{precision = Precision,
collected_metrics = CollectedMetrics} = State) ->
if CollectedMetrics /= #{} ->
?debug("InfluxDB reporter send packet with ~p measurements",
[maps:size(CollectedMetrics)]),
Packets = [make_packet(MetricName, Tags, Fileds, Timestamping, Precision) ++ "\n"
|| {_, {MetricName, Tags, Fileds, Timestamping}}
<- maps:to_list(CollectedMetrics)],
Expand Down
37 changes: 7 additions & 30 deletions src/log.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,15 @@
-define(__LOG_HRL__, true).

%% Lager logging levels
%% debug, info, notice, warning, error, critical, alert, emergency, none.
%% info, warning, error

-define(debug(Fmt), lager:debug(Fmt)).
-define(debug(Fmt, Args), lager:debug(Fmt, Args)).
-define(debug(Attrs, Fmt, Args), lager:debug(Attrs, Fmt, Args)).
-define(info(Fmt), error_logger:info_msg(Fmt ++ "\n")).
-define(info(Fmt, Args), error_logger:info_msg(Fmt ++ "\n", Args)).

-define(info(Fmt), lager:info(Fmt)).
-define(info(Fmt, Args), lager:info(Fmt, Args)).
-define(info(Attrs, Fmt, Args), lager:info(Attrs, Fmt, Args)).
-define(warning(Fmt), error_logger:warning_msg(Fmt ++ "\n")).
-define(warning(Fmt, Args), error_logger:warning_msg(Fmt ++ "\n", Args)).

-define(notice(Fmt), lager:notice(Fmt)).
-define(notice(Fmt, Args), lager:notice(Fmt, Args)).
-define(notice(Attrs, Fmt, Args), lager:notice(Attrs, Fmt, Args)).

-define(warning(Fmt), lager:warning(Fmt)).
-define(warning(Fmt, Args), lager:warning(Fmt, Args)).
-define(warning(Attrs, Fmt, Args), lager:warning(Attrs, Fmt, Args)).

-define(error(Fmt), lager:error(Fmt)).
-define(error(Fmt, Args), lager:error(Fmt, Args)).
-define(error(Attrs, Fmt, Args), lager:error(Attrs, Fmt, Args)).

-define(critical(Fmt), lager:critical(Fmt)).
-define(critical(Fmt, Args), lager:critical(Fmt, Args)).
-define(critical(Attrs, Fmt, Args), lager:critical(Attrs, Fmt, Args)).

-define(alert(Fmt), lager:alert(Fmt)).
-define(alert(Fmt, Args), lager:alert(Fmt, Args)).
-define(alert(Attrs, Fmt, Args), lager:alert(Attrs, Fmt, Args)).

-define(emergency(Fmt), lager:emergency(Fmt)).
-define(emergency(Fmt, Args), lager:emergency(Fmt, Args)).
-define(emergency(Attrs, Fmt, Args), lager:emergency(Attrs, Fmt, Args)).
-define(error(Fmt), error_logger:error_msg(Fmt ++ "\n")).
-define(error(Fmt, Args), error_logger:error_msg(Fmt ++ "\n", Args)).

-endif.

0 comments on commit f09ac7c

Please sign in to comment.