Merge pull request #5908 from zmstone/refactor-emqx-more-slog

refactor(emqx): fix remaining legacy logging
This commit is contained in:
Zaiming (Stone) Shi 2021-10-12 06:45:25 +02:00 committed by GitHub
commit 04f2487108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -66,6 +66,8 @@
, find_listener_conf/3
]).
-include("logger.hrl").
-define(CONF, conf).
-define(RAW_CONF, raw_conf).
-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} ->
init_load(SchemaMod, RawRichConf);
{error, Reason} ->
logger:error(#{msg => failed_to_load_hocon_conf,
?SLOG(error, #{msg => failed_to_load_hocon_conf,
reason => Reason
}),
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
ok -> ok;
{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}
end
end.

View File

@ -20,6 +20,8 @@
, check_pass/2
]).
-include("logger.hrl").
-type(hash_type() :: plain | md5 | sha | sha256 | pbkdf2 | bcrypt).
-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
{ok, Hexstring} ->
pbkdf2:to_hex(Hexstring);
{error, Error} ->
error_logger:error_msg("pbkdf2 hash error:~p", [Error]),
{error, Reason} ->
?SLOG(error, #{msg => "pbkdf2_hash_error", reason => Reason}),
<<>>
end;
hash(bcrypt, {Salt, Password}) ->
@ -76,8 +78,8 @@ hash(bcrypt, {Salt, Password}) ->
case bcrypt:hashpw(Password, Salt) of
{ok, HashPasswd} ->
list_to_binary(HashPasswd);
{error, Error}->
error_logger:error_msg("bcrypt hash error:~p", [Error]),
{error, Reason}->
?SLOG(error, #{msg => "bcrypt_hash_error", reason => Reason}),
<<>>
end.