chore(license): add LICENSE tag to logs
This commit is contained in:
parent
2c81b56377
commit
38e30622f3
|
@ -80,24 +80,29 @@ update_setting(Setting) when is_map(Setting) ->
|
|||
check(_ConnInfo, AckProps) ->
|
||||
case emqx_license_checker:limits() of
|
||||
{ok, #{max_connections := ?ERR_EXPIRED}} ->
|
||||
?SLOG(error, #{msg => "connection_rejected_due_to_license_expired"}),
|
||||
?SLOG(error, #{msg => "connection_rejected_due_to_license_expired"}, #{tag => "LICENSE"}),
|
||||
{stop, {error, ?RC_QUOTA_EXCEEDED}};
|
||||
{ok, #{max_connections := MaxClients}} ->
|
||||
case check_max_clients_exceeded(MaxClients) of
|
||||
true ->
|
||||
?SLOG_THROTTLE(
|
||||
error,
|
||||
#{msg => connection_rejected_due_to_license_limit_reached}
|
||||
#{msg => connection_rejected_due_to_license_limit_reached},
|
||||
#{tag => "LICENSE"}
|
||||
),
|
||||
{stop, {error, ?RC_QUOTA_EXCEEDED}};
|
||||
false ->
|
||||
{ok, AckProps}
|
||||
end;
|
||||
{error, Reason} ->
|
||||
?SLOG(error, #{
|
||||
msg => "connection_rejected_due_to_license_not_loaded",
|
||||
reason => Reason
|
||||
}),
|
||||
?SLOG(
|
||||
error,
|
||||
#{
|
||||
msg => "connection_rejected_due_to_license_not_loaded",
|
||||
reason => Reason
|
||||
},
|
||||
#{tag => "LICENSE"}
|
||||
),
|
||||
{stop, {error, ?RC_QUOTA_EXCEEDED}}
|
||||
end.
|
||||
|
||||
|
|
|
@ -172,11 +172,15 @@ refresh(State) ->
|
|||
State.
|
||||
|
||||
log_new_license(Old, New) ->
|
||||
?SLOG(info, #{
|
||||
msg => "new_license_loaded",
|
||||
old_license => emqx_license_parser:summary(Old),
|
||||
new_license => emqx_license_parser:summary(New)
|
||||
}).
|
||||
?SLOG(
|
||||
info,
|
||||
#{
|
||||
msg => "new_license_loaded",
|
||||
old_license => emqx_license_parser:summary(Old),
|
||||
new_license => emqx_license_parser:summary(New)
|
||||
},
|
||||
#{tag => "LICENSE"}
|
||||
).
|
||||
|
||||
ensure_check_license_timer(#{check_license_interval := CheckInterval} = State) ->
|
||||
ok = cancel_timer(State, check_timer),
|
||||
|
|
|
@ -129,13 +129,17 @@ error_msg(Code, Msg) ->
|
|||
'/license'(post, #{body := #{<<"key">> := Key}}) ->
|
||||
case emqx_license:update_key(Key) of
|
||||
{error, Error} ->
|
||||
?SLOG(error, #{
|
||||
msg => "bad_license_key",
|
||||
reason => Error
|
||||
}),
|
||||
?SLOG(
|
||||
error,
|
||||
#{
|
||||
msg => "bad_license_key",
|
||||
reason => Error
|
||||
},
|
||||
#{tag => "LICENSE"}
|
||||
),
|
||||
{400, error_msg(?BAD_REQUEST, <<"Bad license key">>)};
|
||||
{ok, _} ->
|
||||
?SLOG(info, #{msg => "updated_license_key"}),
|
||||
?SLOG(info, #{msg => "updated_license_key"}, #{tag => "LICENSE"}),
|
||||
License = maps:from_list(emqx_license_checker:dump()),
|
||||
{200, License}
|
||||
end;
|
||||
|
@ -147,13 +151,17 @@ error_msg(Code, Msg) ->
|
|||
'/license/setting'(put, #{body := Setting}) ->
|
||||
case emqx_license:update_setting(Setting) of
|
||||
{error, Error} ->
|
||||
?SLOG(error, #{
|
||||
msg => "bad_license_setting",
|
||||
reason => Error
|
||||
}),
|
||||
?SLOG(
|
||||
error,
|
||||
#{
|
||||
msg => "bad_license_setting",
|
||||
reason => Error
|
||||
},
|
||||
#{tag => "LICENSE"}
|
||||
),
|
||||
{400, error_msg(?BAD_REQUEST, <<"Bad license setting">>)};
|
||||
{ok, _} ->
|
||||
?SLOG(info, #{msg => "updated_license_setting"}),
|
||||
?SLOG(info, #{msg => "updated_license_setting"}, #{tag => "LICENSE"}),
|
||||
'/license/setting'(get, undefined)
|
||||
end.
|
||||
|
||||
|
|
Loading…
Reference in New Issue