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

useless settings json_minimal_level and json_file #1565

Open
matthieumarrast opened this issue Mar 23, 2023 · 0 comments
Open

useless settings json_minimal_level and json_file #1565

matthieumarrast opened this issue Mar 23, 2023 · 0 comments

Comments

@matthieumarrast
Copy link
Contributor

Settings json_file and json_minimal_level in module config.ini does not have any effect when set:

[log]
# Duplicate some log messages in JSON to a specific file (for external
# monitoring tool)
# If json_file value is :
# null => the feature is desactivated
# AUTO => the feature is desactivated (because it's not necessary anymore
#         since 1.2 version)
json_file=log/foo.log

# Minimal level for this json log file
#  DEBUG => everything,
#  INFO => everything but not DEBUG,
#  WARNING => everything but not DEBUG and INFO,
#  ERROR => everything but not DEBUG, INFO and WARNING,
#  CRITICAL => everything but not DEBUG, INFO, WARNING AND ERROR
# Note: you can't send more messages to json log file than the configured global
#       minimal_level level (so also change the value of minimal_level key in
#       these uncommon use-cases)
json_minimal_level=INFO

Problem

In file https://github.com/metwork-framework/mfext/blob/master/adm/templates/profile
the environment variable MFLOG_JSON_FILE does not take any value if different than "AUTO":

# A little kind of magic to deal with [log]/json_file=AUTO
if test "{% raw %}${{% endraw %}{{MFMODULE}}_LOG_JSON_FILE{% raw %}:-}{% endraw %}" = "AUTO"; then
    export MFLOG_JSON_FILE="null"
fi

This variable is used in mflog for writing some logs to a json file, when no json log file is provided !? (see https://github.com/metwork-framework/mflog/blob/master/mflog/utils.py)

Proposed solution

Add export MFLOG_JSON_FILE="${MFDATA_LOG_JSON_FILE:-}" in else condition, as below:

# A little kind of magic to deal with [log]/json_file=AUTO
if test "{% raw %}${{% endraw %}{{MFMODULE}}_LOG_JSON_FILE{% raw %}:-}{% endraw %}" = "AUTO"; then
    export MFLOG_JSON_FILE="null"
else
    export MFLOG_JSON_FILE="${MFDATA_LOG_JSON_FILE:-}"
fi

Also if we set:

json_minimal_level=INFO
json_file=log/foo.log

Now some logs (with INFO level) are now written in file log/foo.log :

{"name": "default", "event": "the mfdata seems to be ok and does not need to be restarted", "level": "info", "pid": 138430, "plugin": "#core#", "timestamp": "2023-03-23T13:15:16.963584Z"}
{"name": "garbage_collector.sh", "event": "Starting...", "level": "info", "pid": 138876, "plugin": "#core#", "timestamp": "2023-03-23T13:16:04.126350Z"}
{"name": "garbage_collector.sh", "event": "End", "level": "info", "pid": 138883, "plugin": "#core#", "timestamp": "2023-03-23T13:16:04.340539Z"}

but I do not know why only the garbage_collector.sh and autorestart, which are also in garbage_collector.log and autorestart.log ... ?

Finality

In MetWork v2 what is the purpose of these settings and this json file ?
I feel like it's totally useless. So maybe we can delete them !? why it has not been done ? for legacy purpose ?
Moreover peoples are lost by the large amount of environment variables around logging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant