Merge pull request #8518 from zhongwencool/fix-logger-json-format-config-not-working

fix: logger json formatter's config not working
This commit is contained in:
zhongwencool 2022-07-22 16:28:46 +08:00 committed by GitHub
commit 2cdd63a2a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -14,6 +14,7 @@
* Fix AuthN JWKS SSL schema. Using schema in `emqx_schema`. [#8458](https://github.com/emqx/emqx/pull/8458) * Fix AuthN JWKS SSL schema. Using schema in `emqx_schema`. [#8458](https://github.com/emqx/emqx/pull/8458)
* `sentinel` field should be required when AuthN/AuthZ Redis using sentinel mode. [#8458](https://github.com/emqx/emqx/pull/8458) * `sentinel` field should be required when AuthN/AuthZ Redis using sentinel mode. [#8458](https://github.com/emqx/emqx/pull/8458)
* Fix bad swagger format. [#8517](https://github.com/emqx/emqx/pull/8517) * Fix bad swagger format. [#8517](https://github.com/emqx/emqx/pull/8517)
* Fix `chars_limit` is not working when `formatter` is `json`. [#8518](http://github.com/emqx/emqx/pull/8518)
* Ensuring that exhook dispatches the client events are sequential. [#8530](https://github.com/emqx/emqx/pull/8530) * Ensuring that exhook dispatches the client events are sequential. [#8530](https://github.com/emqx/emqx/pull/8530)
## Enhancements ## Enhancements

View File

@ -69,9 +69,10 @@ best_effort_json(Input, Opts) ->
jsx:encode(JsonReady, Opts). jsx:encode(JsonReady, Opts).
-spec format(logger:log_event(), config()) -> iodata(). -spec format(logger:log_event(), config()) -> iodata().
format(#{level := Level, msg := Msg, meta := Meta}, Config0) when is_map(Config0) -> format(#{level := Level, msg := Msg, meta := Meta} = Event, Config0) when is_map(Config0) ->
Config = add_default_config(Config0), Config = add_default_config(Config0),
[format(Msg, Meta#{level => Level}, Config), "\n"]. MsgBin = format(Msg, Meta#{level => Level}, Config),
logger_formatter:format(Event#{msg => {string, MsgBin}}, Config).
format(Msg, Meta, Config) -> format(Msg, Meta, Config) ->
Data0 = Data0 =

View File

@ -1039,12 +1039,18 @@ Defaults to: <code>system</code>.
common_handler_chars_limit { common_handler_chars_limit {
desc { desc {
en: """Set the maximum length of a single log message. If this length is exceeded, the log message will be truncated.""" en: """
zh: """设置单个日志消息的最大长度。 如果超过此长度则日志消息将被截断。最小可设置的长度为100。""" Set the maximum length of a single log message. If this length is exceeded, the log message will be truncated.
NOTE: Restrict char limiter if formatter is JSON , it will get a truncated incomplete JSON data, which is not recommended.
"""
zh: """
设置单个日志消息的最大长度。 如果超过此长度则日志消息将被截断。最小可设置的长度为100。
注意:如果日志格式为 JSON限制字符长度可能会导致截断不完整的 JSON 数据。
"""
} }
label { label {
en: "Single Log Max Length" en: "Single Log Max Length"
zh: "单个日志最大长度" zh: "单条日志长度限制"
} }
} }