refactor(emqx): fix remaining legacy logging
This commit is contained in:
parent
40963221f8
commit
eb43423552
|
@ -66,6 +66,8 @@
|
||||||
, find_listener_conf/3
|
, find_listener_conf/3
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
-include("logger.hrl").
|
||||||
|
|
||||||
-define(CONF, conf).
|
-define(CONF, conf).
|
||||||
-define(RAW_CONF, raw_conf).
|
-define(RAW_CONF, raw_conf).
|
||||||
-define(PERSIS_SCHEMA_MODS, {?MODULE, schema_mods}).
|
-define(PERSIS_SCHEMA_MODS, {?MODULE, schema_mods}).
|
||||||
|
@ -250,7 +252,7 @@ init_load(SchemaMod, Conf) when is_list(Conf) orelse is_binary(Conf) ->
|
||||||
{ok, RawRichConf} ->
|
{ok, RawRichConf} ->
|
||||||
init_load(SchemaMod, RawRichConf);
|
init_load(SchemaMod, RawRichConf);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
logger:error(#{msg => failed_to_load_hocon_conf,
|
?SLOG(error, #{msg => failed_to_load_hocon_conf,
|
||||||
reason => Reason
|
reason => Reason
|
||||||
}),
|
}),
|
||||||
error(failed_to_load_hocon_conf)
|
error(failed_to_load_hocon_conf)
|
||||||
|
@ -359,7 +361,9 @@ save_to_override_conf(RawConf) ->
|
||||||
case file:write_file(FileName, hocon_pp:do(RawConf, #{})) of
|
case file:write_file(FileName, hocon_pp:do(RawConf, #{})) of
|
||||||
ok -> ok;
|
ok -> ok;
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
logger:error("write to ~s failed, ~p", [FileName, Reason]),
|
?SLOG(error, #{msg => failed_to_write_override_file,
|
||||||
|
filename => FileName,
|
||||||
|
reason => Reason}),
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
, check_pass/2
|
, check_pass/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
-include("logger.hrl").
|
||||||
|
|
||||||
-type(hash_type() :: plain | md5 | sha | sha256 | pbkdf2 | bcrypt).
|
-type(hash_type() :: plain | md5 | sha | sha256 | pbkdf2 | bcrypt).
|
||||||
|
|
||||||
-export_type([hash_type/0]).
|
-export_type([hash_type/0]).
|
||||||
|
@ -67,8 +69,8 @@ hash(pbkdf2, {Salt, Password, Macfun, Iterations, Dklen}) ->
|
||||||
case pbkdf2:pbkdf2(Macfun, Password, Salt, Iterations, Dklen) of
|
case pbkdf2:pbkdf2(Macfun, Password, Salt, Iterations, Dklen) of
|
||||||
{ok, Hexstring} ->
|
{ok, Hexstring} ->
|
||||||
pbkdf2:to_hex(Hexstring);
|
pbkdf2:to_hex(Hexstring);
|
||||||
{error, Error} ->
|
{error, Reason} ->
|
||||||
error_logger:error_msg("pbkdf2 hash error:~p", [Error]),
|
?SLOG(error, #{msg => "pbkdf2_hash_error", reason => Reason}),
|
||||||
<<>>
|
<<>>
|
||||||
end;
|
end;
|
||||||
hash(bcrypt, {Salt, Password}) ->
|
hash(bcrypt, {Salt, Password}) ->
|
||||||
|
@ -76,8 +78,8 @@ hash(bcrypt, {Salt, Password}) ->
|
||||||
case bcrypt:hashpw(Password, Salt) of
|
case bcrypt:hashpw(Password, Salt) of
|
||||||
{ok, HashPasswd} ->
|
{ok, HashPasswd} ->
|
||||||
list_to_binary(HashPasswd);
|
list_to_binary(HashPasswd);
|
||||||
{error, Error}->
|
{error, Reason}->
|
||||||
error_logger:error_msg("bcrypt hash error:~p", [Error]),
|
?SLOG(error, #{msg => "bcrypt_hash_error", reason => Reason}),
|
||||||
<<>>
|
<<>>
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue