mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Always use lagger
This commit is contained in:
parent
b2c6e397fc
commit
239b1c6f74
13
configure.ac
13
configure.ac
@ -100,9 +100,9 @@ AC_ARG_ENABLE(mssql,
|
|||||||
esac],[db_type=generic])
|
esac],[db_type=generic])
|
||||||
|
|
||||||
AC_ARG_ENABLE(all,
|
AC_ARG_ENABLE(all,
|
||||||
[AC_HELP_STRING([--enable-all], [same as --enable-odbc --enable-mysql --enable-pgsql --enable-sqlite --enable-pam --enable-zlib --enable-riak --enable-redis --enable-elixir --enable-iconv --enable-debug --enable-lager --enable-tools (useful for Dialyzer checks, default: no)])],
|
[AC_HELP_STRING([--enable-all], [same as --enable-odbc --enable-mysql --enable-pgsql --enable-sqlite --enable-pam --enable-zlib --enable-riak --enable-redis --enable-elixir --enable-iconv --enable-debug --enable-tools (useful for Dialyzer checks, default: no)])],
|
||||||
[case "${enableval}" in
|
[case "${enableval}" in
|
||||||
yes) odbc=true mysql=true pgsql=true sqlite=true pam=true zlib=true riak=true redis=true elixir=true iconv=true debug=true lager=true tools=true ;;
|
yes) odbc=true mysql=true pgsql=true sqlite=true pam=true zlib=true riak=true redis=true elixir=true iconv=true debug=true tools=true ;;
|
||||||
no) odbc=false mysql=false pgsql=false sqlite=false pam=false zlib=false riak=false redis=false elixir=false iconv=false debug=false tools=false ;;
|
no) odbc=false mysql=false pgsql=false sqlite=false pam=false zlib=false riak=false redis=false elixir=false iconv=false debug=false tools=false ;;
|
||||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-all) ;;
|
*) AC_MSG_ERROR(bad value ${enableval} for --enable-all) ;;
|
||||||
esac],[])
|
esac],[])
|
||||||
@ -203,14 +203,6 @@ AC_ARG_ENABLE(debug,
|
|||||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
|
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
|
||||||
esac],[if test "x$debug" = "x"; then debug=true; fi])
|
esac],[if test "x$debug" = "x"; then debug=true; fi])
|
||||||
|
|
||||||
AC_ARG_ENABLE(lager,
|
|
||||||
[AC_HELP_STRING([--enable-lager], [enable lager support (default: yes)])],
|
|
||||||
[case "${enableval}" in
|
|
||||||
yes) lager=true ;;
|
|
||||||
no) lager=false ;;
|
|
||||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-lager) ;;
|
|
||||||
esac],[if test "x$lager" = "x"; then lager=true; fi])
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(latest_deps,
|
AC_ARG_ENABLE(latest_deps,
|
||||||
[AC_HELP_STRING([--enable-latest-deps], [makes rebar use latest commits for dependences instead of tagged versions (default: no)])],
|
[AC_HELP_STRING([--enable-latest-deps], [makes rebar use latest commits for dependences instead of tagged versions (default: no)])],
|
||||||
[case "${enableval}" in
|
[case "${enableval}" in
|
||||||
@ -261,7 +253,6 @@ AC_SUBST(redis)
|
|||||||
AC_SUBST(elixir)
|
AC_SUBST(elixir)
|
||||||
AC_SUBST(iconv)
|
AC_SUBST(iconv)
|
||||||
AC_SUBST(debug)
|
AC_SUBST(debug)
|
||||||
AC_SUBST(lager)
|
|
||||||
AC_SUBST(tools)
|
AC_SUBST(tools)
|
||||||
AC_SUBST(latest_deps)
|
AC_SUBST(latest_deps)
|
||||||
AC_SUBST(CFLAGS)
|
AC_SUBST(CFLAGS)
|
||||||
|
@ -18,26 +18,6 @@
|
|||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
-define(PRINT(Format, Args), io:format(Format, Args)).
|
-define(PRINT(Format, Args), io:format(Format, Args)).
|
||||||
|
|
||||||
-ifdef(P1LOGGER).
|
|
||||||
|
|
||||||
-define(DEBUG(Format, Args),
|
|
||||||
p1_logger:debug_msg(?MODULE, ?LINE, Format, Args)).
|
|
||||||
|
|
||||||
-define(INFO_MSG(Format, Args),
|
|
||||||
p1_logger:info_msg(?MODULE, ?LINE, Format, Args)).
|
|
||||||
|
|
||||||
-define(WARNING_MSG(Format, Args),
|
|
||||||
p1_logger:warning_msg(?MODULE, ?LINE, Format, Args)).
|
|
||||||
|
|
||||||
-define(ERROR_MSG(Format, Args),
|
|
||||||
p1_logger:error_msg(?MODULE, ?LINE, Format, Args)).
|
|
||||||
|
|
||||||
-define(CRITICAL_MSG(Format, Args),
|
|
||||||
p1_logger:critical_msg(?MODULE, ?LINE, Format, Args)).
|
|
||||||
|
|
||||||
-else.
|
|
||||||
|
|
||||||
-compile([{parse_transform, lager_transform}]).
|
-compile([{parse_transform, lager_transform}]).
|
||||||
|
|
||||||
-define(DEBUG(Format, Args),
|
-define(DEBUG(Format, Args),
|
||||||
@ -54,5 +34,3 @@
|
|||||||
|
|
||||||
-define(CRITICAL_MSG(Format, Args),
|
-define(CRITICAL_MSG(Format, Args),
|
||||||
lager:critical(Format, Args)).
|
lager:critical(Format, Args)).
|
||||||
|
|
||||||
-endif.
|
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
%%% Created : 1 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
%%% Created : 1 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
{deps, [{if_var_true, lager, {lager, ".*", {git, "https://github.com/basho/lager", {tag, "3.0.2"}}}},
|
{deps, [{lager, ".*", {git, "https://github.com/basho/lager", {tag, "3.0.2"}}},
|
||||||
{if_var_false, lager, {p1_logger, ".*", {git, "https://github.com/processone/p1_logger", {tag, "1.0.0"}}}},
|
|
||||||
{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.3"}}},
|
{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.3"}}},
|
||||||
{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.2"}}},
|
{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.2"}}},
|
||||||
{p1_tls, ".*", {git, "https://github.com/processone/tls", {tag, "1.0.0"}}},
|
{p1_tls, ".*", {git, "https://github.com/processone/tls", {tag, "1.0.0"}}},
|
||||||
@ -53,7 +52,6 @@
|
|||||||
{if_var_false, debug, no_debug_info},
|
{if_var_false, debug, no_debug_info},
|
||||||
{if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}},
|
{if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}},
|
||||||
{if_var_match, db_type, mssql, {d, 'mssql'}},
|
{if_var_match, db_type, mssql, {d, 'mssql'}},
|
||||||
{if_var_false, lager, {d, 'P1LOGGER'}},
|
|
||||||
{if_var_true, erlang_deprecated_types, {d, 'ERL_DEPRECATED_TYPES'}},
|
{if_var_true, erlang_deprecated_types, {d, 'ERL_DEPRECATED_TYPES'}},
|
||||||
{if_var_true, hipe, native},
|
{if_var_true, hipe, native},
|
||||||
{src_dirs, [asn1, src,
|
{src_dirs, [asn1, src,
|
||||||
|
@ -74,68 +74,6 @@ opt_type(log_rate_limit) ->
|
|||||||
opt_type(_) ->
|
opt_type(_) ->
|
||||||
[log_rotate_date, log_rotate_size, log_rotate_count, log_rate_limit].
|
[log_rotate_date, log_rotate_size, log_rotate_count, log_rate_limit].
|
||||||
|
|
||||||
%% Default logger module is LAGER, defined in else clause.
|
|
||||||
%% TODO: Remove p1_logger usage and allow using Elixir logger if running in Elixir context.
|
|
||||||
-ifdef(P1LOGGER).
|
|
||||||
|
|
||||||
start() ->
|
|
||||||
set(4),
|
|
||||||
LogPath = get_log_path(),
|
|
||||||
error_logger:add_report_handler(p1_logger_h, LogPath),
|
|
||||||
ok.
|
|
||||||
|
|
||||||
reopen_log() ->
|
|
||||||
%% TODO: Use the Reopen log API for logger_h ?
|
|
||||||
p1_logger_h:reopen_log(),
|
|
||||||
reopen_sasl_log().
|
|
||||||
|
|
||||||
rotate_log() ->
|
|
||||||
%% Not implemented.
|
|
||||||
ok.
|
|
||||||
|
|
||||||
get() ->
|
|
||||||
p1_loglevel:get().
|
|
||||||
|
|
||||||
set(LogLevel) when LogLevel >=0, LogLevel =< 5 ->
|
|
||||||
p1_loglevel:set(LogLevel);
|
|
||||||
set(LogLevel) ->
|
|
||||||
throw({wrong_loglevel, LogLevel}).
|
|
||||||
|
|
||||||
%%%===================================================================
|
|
||||||
%%% Internal functions
|
|
||||||
%%%===================================================================
|
|
||||||
reopen_sasl_log() ->
|
|
||||||
case application:get_env(sasl,sasl_error_logger) of
|
|
||||||
{ok, {file, SASLfile}} ->
|
|
||||||
error_logger:delete_report_handler(sasl_report_file_h),
|
|
||||||
rotate_sasl_log(SASLfile),
|
|
||||||
error_logger:add_report_handler(sasl_report_file_h,
|
|
||||||
{SASLfile, get_sasl_error_logger_type()});
|
|
||||||
_ -> false
|
|
||||||
end,
|
|
||||||
ok.
|
|
||||||
|
|
||||||
rotate_sasl_log(Filename) ->
|
|
||||||
case file:read_file_info(Filename) of
|
|
||||||
{ok, _FileInfo} ->
|
|
||||||
file:rename(Filename, [Filename, ".0"]),
|
|
||||||
ok;
|
|
||||||
{error, _Reason} ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
%% Function copied from Erlang/OTP lib/sasl/src/sasl.erl which doesn't export it
|
|
||||||
get_sasl_error_logger_type () ->
|
|
||||||
case application:get_env (sasl, errlog_type) of
|
|
||||||
{ok, error} -> error;
|
|
||||||
{ok, progress} -> progress;
|
|
||||||
{ok, all} -> all;
|
|
||||||
{ok, Bad} -> exit ({bad_config, {sasl, {errlog_type, Bad}}});
|
|
||||||
_ -> all
|
|
||||||
end.
|
|
||||||
|
|
||||||
-else.
|
|
||||||
|
|
||||||
get_integer_env(Name, Default) ->
|
get_integer_env(Name, Default) ->
|
||||||
case application:get_env(ejabberd, Name) of
|
case application:get_env(ejabberd, Name) of
|
||||||
{ok, I} when is_integer(I), I>=0 ->
|
{ok, I} when is_integer(I), I>=0 ->
|
||||||
@ -242,5 +180,3 @@ set(LogLevel) when is_integer(LogLevel) ->
|
|||||||
set({_LogLevel, _}) ->
|
set({_LogLevel, _}) ->
|
||||||
error_logger:error_msg("custom loglevels are not supported for 'lager'"),
|
error_logger:error_msg("custom loglevels are not supported for 'lager'"),
|
||||||
{module, lager}.
|
{module, lager}.
|
||||||
|
|
||||||
-endif.
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
{riak, @riak@}.
|
{riak, @riak@}.
|
||||||
{redis, @redis@}.
|
{redis, @redis@}.
|
||||||
{elixir, @elixir@}.
|
{elixir, @elixir@}.
|
||||||
{lager, @lager@}.
|
|
||||||
{iconv, @iconv@}.
|
{iconv, @iconv@}.
|
||||||
|
|
||||||
%% Version
|
%% Version
|
||||||
|
Loading…
Reference in New Issue
Block a user