summaryrefslogtreecommitdiffstats
path: root/daemon/main.c
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2023-10-02 14:14:59 -0300
committerGitHub <noreply@github.com>2023-10-02 20:14:59 +0300
commita16bfec2e7afef4cecd2e24cf95af5f6e5e60244 (patch)
tree76d72f4b2818fbf616149f9531dac612f557b366 /daemon/main.c
parent00f79017f9d2c45289eaa6939b418d5a9084e906 (diff)
Severity level for logs (#14727)
* log_level: Add new data type and variable used to control log level * log_level: Add helper and constants used to simplify user life when they are setting log level. I initially thought to create a log_select_log_level as void, but I thought the worse would be to have a variable defined inside a function, instead tto set outside like other calls inside log_init is doing. * log_level: Modify option name to match https://github.com/netdata/netdata/issues/14388#issuecomment-1412188747 * log_level: Modify function info_int to store data according user defintion for new variable * log_level: Modify function error_int to match new variable configuration. * documentation_adjust_code: After to clarify goals, I am removing level that is not necessary. * documentation_adjust_code: Pass serverity-level as argument for plugins. I had to modify the argument in this commit, because plugins like apps have specific algorithm to parse the arguments. * documentation_adjust_code: As informed in previous commit, to avoid modify all plugins, I am renaming configuration option. * documentation_adjust_code: Add new helper to modify log level from collectors and also modify the first collector (apps.plugin) * documentation_adjust_code: Modify cgroup-network to use severity-level * documentation_adjust_code: Add missing documentation for apps plugin * documentation_adjust_code: Modify cups.plugin to use severity-level * documentation_adjust_code: Modify ebpf.plugin to use severity-level * documentation_adjust_code: Modify freeimpi.plugin to use severity-level * documentation_adjust_code: Modify nfacct.plugin to use severity-level * documentation_adjust_code: Modify perf.plugin to use severity-level * documentation_adjust_code: Modify slab.plugin to use severity-level * documentation_adjust_code: Fix python.plugin * log_level: Revert condition added for info_int, because in any situation we will have INFO data * log_level: Rename function to match new circustances and add an argument instead to create another function that would have the same algorithm * log_level: The eBPF.plugin without this commit will not work properly with new variables, on the other hand the proper solution needs more than 14 lines of code. So I am pushing this commit to achieve the goal and simplify my reviewers. * log_level: Add additional information for our documentation * log_level: Bring initial changes for Plugin classes * log_level: Rename log_level to use_severity_level to simplify code read * log_level: Rename functions for a more meaningful name and also add a new function to pass the same value for all collectors * log_level: Modify all collectors to receive string as argument instead integer, this will simplify for developers that want to work with dictionary, and also we will have one unique common value for core/collectors. * log_level: Modify cgroup to inform cgroup_network what is the current severity_level * log_level: Modify class JobsConfigBuilder to use external severity level * log_level: Modify PythonDLogger class and add arguments for callers * log_level: Address flake8 * log_level: Modify daemon/config/README.md adding information about new log file and also new option * log_level: Accept suggestion given in https://github.com/netdata/netdata/pull/14727#pullrequestreview-1361221097 * log_level: Add informatin about tags with a link to configuration doc * ebpf_functions: Fix rebase. * rename_error_fcnt: Fix previous rebase and rebase again * log_level: Moddfy charts. * log_level: Modify tc-qos-helper to dispach message according security-level * log_level: Fix charts.d and typo * log_level: Remove unnecesary cast * log_level: Fix rebase * Fix rebase * log_level: Fix shellcheck * log_level: Remove severity level for external plugins * log_level: Remove severity level for external plugins (2) * log_level: Remove severity level for external plugins (cgrooup) * log_level: Restore cgroup line * log_level: Only set severity when developers do not need message * log_level: Add environment variable to communicate with external plugin and modify default level. * log_level: Modify functions to use severity level * Apply suggestions from code review fix sev level/global sev level comparison * rename var and add err short str * simplify logic in log level cmp * update docs * fix log_severity_level_to_severity_string * Update daemon/README.md --------- Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
Diffstat (limited to 'daemon/main.c')
-rw-r--r--daemon/main.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/daemon/main.c b/daemon/main.c
index 9460223a4c..59c02bb498 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -874,6 +874,10 @@ static void log_init(void) {
setenv("NETDATA_ERRORS_THROTTLE_PERIOD", config_get(CONFIG_SECTION_LOGS, "errors flood protection period" , ""), 1);
setenv("NETDATA_ERRORS_PER_PERIOD", config_get(CONFIG_SECTION_LOGS, "errors to trigger flood protection", ""), 1);
+
+ char *selected_level = config_get(CONFIG_SECTION_LOGS, "severity level", NETDATA_LOG_LEVEL_INFO_STR);
+ global_log_severity_level = log_severity_string_to_severity_level(selected_level);
+ setenv("NETDATA_LOG_SEVERITY_LEVEL", selected_level , 1);
}
char *initialize_lock_directory_path(char *prefix)