Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor log configuration to be consistent with log doc guide #1335

Merged
merged 4 commits into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ define PROJECT_ENV
{auth_backends, [rabbit_auth_backend_internal]},
{delegate_count, 16},
{trace_vhosts, []},
{log_levels, [{connection, info}]},
{ssl_cert_login_from, distinguished_name},
{ssl_handshake_timeout, 5000},
{ssl_allow_poodle_attack, false},
Expand Down
124 changes: 71 additions & 53 deletions priv/schema/rabbit.schema
Original file line number Diff line number Diff line change
Expand Up @@ -990,80 +990,98 @@ end}.
{datatype, string},
{validators, ["dir_writable"]}]}.

{mapping, "log.console", "lager.handlers", [
{mapping, "log.console", "rabbit.log.console.enabled", [
{datatype, {enum, [true, false]}}
]}.
{mapping, "log.console.level", "rabbit.log.console.level", [
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.

{mapping, "log.syslog", "lager.handlers", [
{mapping, "log.syslog", "rabbit.log.syslog.enabled", [
{datatype, {enum, [true, false]}}
]}.
{mapping, "log.file", "lager.handlers", [
{datatype, [{enum, [false]}, string]}
{mapping, "log.syslog.level", "rabbit.log.syslog.level", [
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.
{mapping, "log.syslog.identity", "rabbit.log.syslog.identity", [
{datatype, string}
]}.
{mapping, "log.syslog.facility", "rabbit.log.syslog.facility", [
{datatype, atom}
]}.

{mapping, "log.file.level", "lager.handlers", [
{datatype, {enum, [debug, info, warning, error]}}
{mapping, "log.file", "rabbit.log.file.file", [
{datatype, [{enum, [false]}, string]}
]}.
{mapping, "log.$handler.level", "lager.handlers", [
{datatype, {enum, [debug, info, warning, error]}}
{mapping, "log.file.level", "rabbit.log.file.level", [
{datatype,
{enum, ['=debug', debug,
info, '!=info',
notice, '<=notice',
'<warning', warning,
error,
critical,
alert,
emergency,
none]}}
]}.
{mapping, "log.file.rotation.date", "lager.handlers", [
{mapping, "log.file.rotation.date", "rabbit.log.file.date", [
{datatype, string}
]}.
{mapping, "log.file.rotation.size", "lager.handlers", [
{mapping, "log.file.rotation.size", "rabbit.log.file.size", [
{datatype, integer}
]}.
{mapping, "log.file.rotation.count", "lager.handlers", [
{mapping, "log.file.rotation.count", "rabbit.log.file.count", [
{datatype, integer}
]}.

{mapping, "log.syslog.identity", "lager.handlers", [
%% Log categories

{mapping, "log.connection.level", "rabbit.log.categories.connection.level", [
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.
{mapping, "log.connection.file", "rabbit.log.categories.connection.file", [
{datatype, string}
]}.
{mapping, "log.syslog.facility", "lager.handlers", [
{datatype, atom}

{mapping, "log.channel.level", "rabbit.log.categories.channel.level", [
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.
{mapping, "log.channel.file", "rabbit.log.categories.channel.file", [
{datatype, string}
]}.

{translation, "lager.handlers",
fun(Conf) ->
ConsoleHandler = case cuttlefish:conf_get("log.console", Conf, false) of
true ->
ConsoleLevel = cuttlefish:conf_get("log.console.level", Conf, info),
[{lager_console_backend, ConsoleLevel}];
false -> []
end,
FileHandler = case cuttlefish:conf_get("log.file", Conf, undefined) of
false -> [];
File ->
FileLevel = cuttlefish:conf_get("log.file.level", Conf, info),
RotationDate = cuttlefish:conf_get("log.file.rotation.date", Conf, ""),
RotationSize = cuttlefish:conf_get("log.file.rotation.size", Conf, 0),
RotationCount = cuttlefish:conf_get("log.file.rotation.count", Conf, 10),
[{lager_file_backend, [{file, File},
{level, FileLevel},
{date, RotationDate},
{size, RotationSize},
{formatter_config,
[date, " ", time, " ", color,
"[", severity, "] ",
{pid, ""},
" ", message, "\n"]},
{count, RotationCount}]}]
end,
SyslogHandler = case cuttlefish:conf_get("log.syslog", Conf, false) of
false -> [];
true ->
SyslogLevel = cuttlefish:conf_get("log.syslog.level", Conf, info),
Identity = cuttlefish:conf_get("log.syslog.identity", Conf),
Facility = cuttlefish:conf_get("log.syslog.facility", Conf),
[{lager_syslog_backend, [Identity, Facility, SyslogLevel]}]
end,
case ConsoleHandler ++ FileHandler ++ SyslogHandler of
[] -> undefined;
Other -> Other
end
end}.
{mapping, "log.mirroring.level", "rabbit.log.categories.mirroring.level", [
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.
{mapping, "log.mirroring.file", "rabbit.log.categories.mirroring.file", [
{datatype, string}
]}.

{mapping, "log.queue.level", "rabbit.log.categories.queue.level", [
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.
{mapping, "log.queue.file", "rabbit.log.categories.queue.file", [
{datatype, string}
]}.

{mapping, "log.federation.level", "rabbit.log.categories.federation.level", [
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.
{mapping, "log.federation.file", "rabbit.log.categories.federation.file", [
{datatype, string}
]}.

{mapping, "log.upgrade.level", "rabbit.log.categories.upgrade.level", [
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.
{mapping, "log.upgrade.file", "rabbit.log.categories.upgrade.file", [
{datatype, string}
]}.

{mapping, "log.default.level", "rabbit.log.categories.default.level", [
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.

% ===============================
% Validators
Expand Down
4 changes: 2 additions & 2 deletions scripts/rabbitmq-server
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ start_rabbitmq_server() {
-sasl errlog_type error \
-sasl sasl_error_logger "$SASL_ERROR_LOGGER" \
-rabbit lager_log_root "\"$RABBITMQ_LOG_BASE\"" \
-rabbit lager_handler "$RABBIT_LAGER_HANDLER" \
-rabbit lager_handler_upgrade "$RABBITMQ_LAGER_HANDLER_UPGRADE" \
-rabbit lager_default_file "$RABBIT_LAGER_HANDLER" \
-rabbit lager_upgrade_file "$RABBITMQ_LAGER_HANDLER_UPGRADE" \
-rabbit enabled_plugins_file "\"$RABBITMQ_ENABLED_PLUGINS_FILE\"" \
-rabbit plugins_dir "\"$RABBITMQ_PLUGINS_DIR\"" \
-rabbit plugins_expand_dir "\"$RABBITMQ_PLUGINS_EXPAND_DIR\"" \
Expand Down
Loading