From f672f4a95584da2a9978f5dca11eba34dc8a8c3b Mon Sep 17 00:00:00 2001 From: thiagoftsm Date: Tue, 11 Jul 2023 14:45:16 +0000 Subject: Rename log Macros (debug) (#15322) --- libnetdata/buffer/buffer.c | 10 ++-- libnetdata/config/appconfig.c | 28 +++++------ libnetdata/dictionary/dictionary.c | 20 ++++---- libnetdata/ebpf/ebpf.c | 1 - libnetdata/health/health.c | 12 ++--- libnetdata/libnetdata.c | 18 +++---- libnetdata/locks/locks.c | 20 ++++---- libnetdata/log/log.h | 4 +- libnetdata/os.c | 2 +- libnetdata/popen/popen.c | 2 +- libnetdata/procfile/procfile.c | 46 ++++++++--------- libnetdata/simple_pattern/simple_pattern.c | 4 +- libnetdata/socket/security.c | 4 +- libnetdata/socket/socket.c | 80 +++++++++++++++--------------- libnetdata/threads/threads.c | 2 +- 15 files changed, 126 insertions(+), 127 deletions(-) (limited to 'libnetdata') diff --git a/libnetdata/buffer/buffer.c b/libnetdata/buffer/buffer.c index c54382abd3..b437628633 100644 --- a/libnetdata/buffer/buffer.c +++ b/libnetdata/buffer/buffer.c @@ -107,7 +107,7 @@ void buffer_vsprintf(BUFFER *wb, const char *fmt, va_list args) do { need += space_remaining * 2; - debug(D_WEB_BUFFER, "web_buffer_sprintf(): increasing web_buffer at position %zu, size = %zu, by %zu bytes (wrote = %zu)\n", wb->len, wb->size, need, wrote); + netdata_log_debug(D_WEB_BUFFER, "web_buffer_sprintf(): increasing web_buffer at position %zu, size = %zu, by %zu bytes (wrote = %zu)\n", wb->len, wb->size, need, wrote); buffer_need_bytes(wb, need); space_remaining = wb->size - wb->len - 1; @@ -131,7 +131,7 @@ void buffer_sprintf(BUFFER *wb, const char *fmt, ...) do { need += space_remaining * 2; - debug(D_WEB_BUFFER, "web_buffer_sprintf(): increasing web_buffer at position %zu, size = %zu, by %zu bytes (wrote = %zu)\n", wb->len, wb->size, need, wrote); + netdata_log_debug(D_WEB_BUFFER, "web_buffer_sprintf(): increasing web_buffer at position %zu, size = %zu, by %zu bytes (wrote = %zu)\n", wb->len, wb->size, need, wrote); buffer_need_bytes(wb, need); space_remaining = wb->size - wb->len - 1; @@ -246,7 +246,7 @@ BUFFER *buffer_create(size_t size, size_t *statistics) { BUFFER *b; - debug(D_WEB_BUFFER, "Creating new web buffer of size %zu.", size); + netdata_log_debug(D_WEB_BUFFER, "Creating new web buffer of size %zu.", size); b = callocz(1, sizeof(BUFFER)); b->buffer = mallocz(size + sizeof(BUFFER_OVERFLOW_EOF) + 2); @@ -268,7 +268,7 @@ void buffer_free(BUFFER *b) { buffer_overflow_check(b); - debug(D_WEB_BUFFER, "Freeing web buffer of size %zu.", b->size); + netdata_log_debug(D_WEB_BUFFER, "Freeing web buffer of size %zu.", b->size); if(b->statistics) __atomic_sub_fetch(b->statistics, b->size + sizeof(BUFFER) + sizeof(BUFFER_OVERFLOW_EOF) + 2, __ATOMIC_RELAXED); @@ -290,7 +290,7 @@ void buffer_increase(BUFFER *b, size_t free_size_required) { size_t optimal = (b->size > 5*1024*1024) ? b->size / 2 : b->size; if(optimal > wanted) wanted = optimal; - debug(D_WEB_BUFFER, "Increasing data buffer from size %zu to %zu.", b->size, b->size + wanted); + netdata_log_debug(D_WEB_BUFFER, "Increasing data buffer from size %zu to %zu.", b->size, b->size + wanted); b->buffer = reallocz(b->buffer, b->size + wanted + sizeof(BUFFER_OVERFLOW_EOF) + 2); b->size += wanted; diff --git a/libnetdata/config/appconfig.c b/libnetdata/config/appconfig.c index 59a1da7897..fe4c1222d4 100644 --- a/libnetdata/config/appconfig.c +++ b/libnetdata/config/appconfig.c @@ -164,7 +164,7 @@ static inline struct section *appconfig_section_find(struct config *root, const } static inline struct section *appconfig_section_create(struct config *root, const char *section) { - debug(D_CONFIG, "Creating section '%s'.", section); + netdata_log_debug(D_CONFIG, "Creating section '%s'.", section); struct section *co = callocz(1, sizeof(struct section)); co->name = strdupz(section); @@ -194,7 +194,7 @@ void appconfig_section_destroy_non_loaded(struct config *root, const char *secti struct section *co; struct config_option *cv, *cv_next; - debug(D_CONFIG, "Destroying section '%s'.", section); + netdata_log_debug(D_CONFIG, "Destroying section '%s'.", section); co = appconfig_section_find(root, section); if(!co) { @@ -259,7 +259,7 @@ void appconfig_section_destroy_non_loaded(struct config *root, const char *secti void appconfig_section_option_destroy_non_loaded(struct config *root, const char *section, const char *name) { - debug(D_CONFIG, "Destroying section option '%s -> %s'.", section, name); + netdata_log_debug(D_CONFIG, "Destroying section option '%s -> %s'.", section, name); struct section *co; co = appconfig_section_find(root, section); @@ -310,7 +310,7 @@ void appconfig_section_option_destroy_non_loaded(struct config *root, const char // config name-value methods static inline struct config_option *appconfig_value_create(struct section *co, const char *name, const char *value) { - debug(D_CONFIG, "Creating config entry for name '%s', value '%s', in section '%s'.", name, value, co->name); + netdata_log_debug(D_CONFIG, "Creating config entry for name '%s', value '%s', in section '%s'.", name, value, co->name); struct config_option *cv = callocz(1, sizeof(struct config_option)); cv->name = strdupz(name); @@ -341,7 +341,7 @@ static inline struct config_option *appconfig_value_create(struct section *co, c int appconfig_exists(struct config *root, const char *section, const char *name) { struct config_option *cv; - debug(D_CONFIG, "request to get config in section '%s', name '%s'", section, name); + netdata_log_debug(D_CONFIG, "request to get config in section '%s', name '%s'", section, name); struct section *co = appconfig_section_find(root, section); if(!co) return 0; @@ -356,7 +356,7 @@ int appconfig_move(struct config *root, const char *section_old, const char *nam struct config_option *cv_old, *cv_new; int ret = -1; - debug(D_CONFIG, "request to rename config in section '%s', old name '%s', to section '%s', new name '%s'", section_old, name_old, section_new, name_new); + netdata_log_debug(D_CONFIG, "request to rename config in section '%s', old name '%s', to section '%s', new name '%s'", section_old, name_old, section_new, name_new); struct section *co_old = appconfig_section_find(root, section_old); if(!co_old) return ret; @@ -439,9 +439,9 @@ char *appconfig_get_by_section(struct section *co, const char *name, const char char *appconfig_get(struct config *root, const char *section, const char *name, const char *default_value) { if (default_value == NULL) - debug(D_CONFIG, "request to get config in section '%s', name '%s' or fail", section, name); + netdata_log_debug(D_CONFIG, "request to get config in section '%s', name '%s' or fail", section, name); else - debug(D_CONFIG, "request to get config in section '%s', name '%s', default_value '%s'", section, name, default_value); + netdata_log_debug(D_CONFIG, "request to get config in section '%s', name '%s', default_value '%s'", section, name, default_value); struct section *co = appconfig_section_find(root, section); if (!co && !default_value) @@ -532,7 +532,7 @@ const char *appconfig_set_default(struct config *root, const char *section, cons { struct config_option *cv; - debug(D_CONFIG, "request to set default config in section '%s', name '%s', value '%s'", section, name, value); + netdata_log_debug(D_CONFIG, "request to set default config in section '%s', name '%s', value '%s'", section, name, value); struct section *co = appconfig_section_find(root, section); if(!co) return appconfig_set(root, section, name, value); @@ -559,7 +559,7 @@ const char *appconfig_set(struct config *root, const char *section, const char * { struct config_option *cv; - debug(D_CONFIG, "request to set config in section '%s', name '%s', value '%s'", section, name, value); + netdata_log_debug(D_CONFIG, "request to set config in section '%s', name '%s', value '%s'", section, name, value); struct section *co = appconfig_section_find(root, section); if(!co) co = appconfig_section_create(root, section); @@ -649,7 +649,7 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons if(!filename) filename = CONFIG_DIR "/" CONFIG_FILENAME; - debug(D_CONFIG, "CONFIG: opening config file '%s'", filename); + netdata_log_debug(D_CONFIG, "CONFIG: opening config file '%s'", filename); FILE *fp = fopen(filename, "r"); if(!fp) { @@ -669,7 +669,7 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons s = trim(buffer); if(!s || *s == '#') { - debug(D_CONFIG, "CONFIG: ignoring line %d of file '%s', it is empty.", line, filename); + netdata_log_debug(D_CONFIG, "CONFIG: ignoring line %d of file '%s', it is empty.", line, filename); continue; } @@ -778,12 +778,12 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons } } else { if (((cv->flags & CONFIG_VALUE_USED) && overwrite_used) || !(cv->flags & CONFIG_VALUE_USED)) { - debug( + netdata_log_debug( D_CONFIG, "CONFIG: line %d of file '%s', overwriting '%s/%s'.", line, filename, co->name, cv->name); freez(cv->value); cv->value = strdupz(value); } else - debug( + netdata_log_debug( D_CONFIG, "CONFIG: ignoring line %d of file '%s', '%s/%s' is already present and used.", line, diff --git a/libnetdata/dictionary/dictionary.c b/libnetdata/dictionary/dictionary.c index bb76e6f6f1..05da553444 100644 --- a/libnetdata/dictionary/dictionary.c +++ b/libnetdata/dictionary/dictionary.c @@ -1065,7 +1065,7 @@ static size_t hashtable_destroy_unsafe(DICTIONARY *dict) { JU_ERRNO(&J_Error), JU_ERRID(&J_Error)); } - debug(D_DICTIONARY, "Dictionary: hash table freed %lu bytes", ret); + netdata_log_debug(D_DICTIONARY, "Dictionary: hash table freed %lu bytes", ret); dict->index.JudyHSArray = NULL; return (size_t)ret; @@ -1376,7 +1376,7 @@ static void dict_item_reset_value_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM * if(unlikely(is_view_dictionary(dict))) fatal("DICTIONARY: %s() should never be called on views.", __FUNCTION__ ); - debug(D_DICTIONARY, "Dictionary entry with name '%s' found. Changing its value.", item_get_name(item)); + netdata_log_debug(D_DICTIONARY, "Dictionary entry with name '%s' found. Changing its value.", item_get_name(item)); DICTIONARY_VALUE_RESETS_PLUS1(dict); @@ -1388,12 +1388,12 @@ static void dict_item_reset_value_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM * dictionary_execute_delete_callback(dict, item); if(likely(dict->options & DICT_OPTION_VALUE_LINK_DONT_CLONE)) { - debug(D_DICTIONARY, "Dictionary: linking value to '%s'", item_get_name(item)); + netdata_log_debug(D_DICTIONARY, "Dictionary: linking value to '%s'", item_get_name(item)); item->shared->value = value; item->shared->value_len = value_len; } else { - debug(D_DICTIONARY, "Dictionary: cloning value to '%s'", item_get_name(item)); + netdata_log_debug(D_DICTIONARY, "Dictionary: cloning value to '%s'", item_get_name(item)); void *old_value = item->shared->value; void *new_value = NULL; @@ -1405,7 +1405,7 @@ static void dict_item_reset_value_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM * item->shared->value = new_value; item->shared->value_len = value_len; - debug(D_DICTIONARY, "Dictionary: freeing old value of '%s'", item_get_name(item)); + netdata_log_debug(D_DICTIONARY, "Dictionary: freeing old value of '%s'", item_get_name(item)); dict_item_value_freez(dict, old_value); } @@ -1413,7 +1413,7 @@ static void dict_item_reset_value_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM * } static size_t dict_item_free_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM *item) { - debug(D_DICTIONARY, "Destroying name value entry for name '%s'.", item_get_name(item)); + netdata_log_debug(D_DICTIONARY, "Destroying name value entry for name '%s'.", item_get_name(item)); if(!item_flag_check(item, ITEM_FLAG_DELETED)) DICTIONARY_ENTRIES_MINUS1(dict); @@ -1428,7 +1428,7 @@ static size_t dict_item_free_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM *item) dictionary_execute_delete_callback(dict, item); if(unlikely(!(dict->options & DICT_OPTION_VALUE_LINK_DONT_CLONE))) { - debug(D_DICTIONARY, "Dictionary freeing value of '%s'", item_get_name(item)); + netdata_log_debug(D_DICTIONARY, "Dictionary freeing value of '%s'", item_get_name(item)); dict_item_value_freez(dict, item->shared->value); item->shared->value = NULL; } @@ -1554,7 +1554,7 @@ static bool dict_item_del(DICTIONARY *dict, const char *name, ssize_t name_len) if(name_len == -1) name_len = (ssize_t)strlen(name) + 1; // we need the terminating null too - debug(D_DICTIONARY, "DEL dictionary entry with name '%s'.", name); + netdata_log_debug(D_DICTIONARY, "DEL dictionary entry with name '%s'.", name); // Unfortunately, the JudyHSDel() does not return the value of the // item that was deleted, so we have to find it before we delete it, @@ -1605,7 +1605,7 @@ static DICTIONARY_ITEM *dict_item_add_or_reset_value_and_acquire(DICTIONARY *dic if(name_len == -1) name_len = (ssize_t)strlen(name) + 1; // we need the terminating null too - debug(D_DICTIONARY, "SET dictionary entry with name '%s'.", name); + netdata_log_debug(D_DICTIONARY, "SET dictionary entry with name '%s'.", name); // DISCUSSION: // Is it better to gain a read-lock and do a hashtable_get_unsafe() @@ -1724,7 +1724,7 @@ static DICTIONARY_ITEM *dict_item_find_and_acquire(DICTIONARY *dict, const char if(name_len == -1) name_len = (ssize_t)strlen(name) + 1; // we need the terminating null too - debug(D_DICTIONARY, "GET dictionary entry with name '%s'.", name); + netdata_log_debug(D_DICTIONARY, "GET dictionary entry with name '%s'.", name); dictionary_index_lock_rdlock(dict); diff --git a/libnetdata/ebpf/ebpf.c b/libnetdata/ebpf/ebpf.c index c41a0021ee..ed7aa9a4c9 100644 --- a/libnetdata/ebpf/ebpf.c +++ b/libnetdata/ebpf/ebpf.c @@ -44,7 +44,6 @@ static int clean_kprobe_event(FILE *out, char *filename, char *father_pid, netda int clean_kprobe_events(FILE *out, int pid, netdata_ebpf_events_t *ptr) { - debug(D_EXIT, "Cleaning parent process events."); char filename[FILENAME_MAX + 1]; snprintf(filename, FILENAME_MAX, "%s%s", NETDATA_DEBUGFS, "kprobe_events"); diff --git a/libnetdata/health/health.c b/libnetdata/health/health.c index 505df4e5ab..53ebecb42a 100644 --- a/libnetdata/health/health.c +++ b/libnetdata/health/health.c @@ -11,7 +11,7 @@ SILENCERS *silencers; */ SILENCER *create_silencer(void) { SILENCER *t = callocz(1, sizeof(SILENCER)); - debug(D_HEALTH, "HEALTH command API: Created empty silencer"); + netdata_log_debug(D_HEALTH, "HEALTH command API: Created empty silencer"); return t; } @@ -27,7 +27,7 @@ void health_silencers_add(SILENCER *silencer) { // Add the created instance to the linked list in silencers silencer->next = silencers->silencers; silencers->silencers = silencer; - debug(D_HEALTH, "HEALTH command API: Added silencer %s:%s:%s:%s:%s", silencer->alarms, + netdata_log_debug(D_HEALTH, "HEALTH command API: Added silencer %s:%s:%s:%s:%s", silencer->alarms, silencer->charts, silencer->contexts, silencer->hosts, silencer->families ); } @@ -116,7 +116,7 @@ int health_silencers_json_read_callback(JSON_ENTRY *e) e->callback_function = health_silencers_json_read_callback; if(strcmp(e->name,"")) { // init silencer - debug(D_HEALTH, "JSON: Got object with a name, initializing new silencer for %s",e->name); + netdata_log_debug(D_HEALTH, "JSON: Got object with a name, initializing new silencer for %s",e->name); #endif e->callback_data = create_silencer(); if(e->callback_data) { @@ -133,18 +133,18 @@ int health_silencers_json_read_callback(JSON_ENTRY *e) case JSON_STRING: if(!strcmp(e->name,"type")) { - debug(D_HEALTH, "JSON: Processing type=%s",e->data.string); + netdata_log_debug(D_HEALTH, "JSON: Processing type=%s",e->data.string); if (!strcmp(e->data.string,"SILENCE")) silencers->stype = STYPE_SILENCE_NOTIFICATIONS; else if (!strcmp(e->data.string,"DISABLE")) silencers->stype = STYPE_DISABLE_ALARMS; } else { - debug(D_HEALTH, "JSON: Adding %s=%s", e->name, e->data.string); + netdata_log_debug(D_HEALTH, "JSON: Adding %s=%s", e->name, e->data.string); if (e->callback_data) (void)health_silencers_addparam(e->callback_data, e->name, e->data.string); } break; case JSON_BOOLEAN: - debug(D_HEALTH, "JSON: Processing all_alarms"); + netdata_log_debug(D_HEALTH, "JSON: Processing all_alarms"); silencers->all_alarms=e->data.boolean?1:0; break; diff --git a/libnetdata/libnetdata.c b/libnetdata/libnetdata.c index 0174d4d3d7..272ba8f17a 100644 --- a/libnetdata/libnetdata.c +++ b/libnetdata/libnetdata.c @@ -1529,7 +1529,7 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p char *udir = strdupz_path_subpath(user_path, subpath); char *sdir = strdupz_path_subpath(stock_path, subpath); - debug(D_HEALTH, "CONFIG traversing user-config directory '%s', stock config directory '%s'", udir, sdir); + netdata_log_debug(D_HEALTH, "CONFIG traversing user-config directory '%s', stock config directory '%s'", udir, sdir); DIR *dir = opendir(udir); if (!dir) { @@ -1543,7 +1543,7 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p (de->d_name[0] == '.' && de->d_name[1] == '\0') || (de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0') ) { - debug(D_HEALTH, "CONFIG ignoring user-config directory '%s/%s'", udir, de->d_name); + netdata_log_debug(D_HEALTH, "CONFIG ignoring user-config directory '%s/%s'", udir, de->d_name); continue; } @@ -1558,20 +1558,20 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p if(path_is_file(udir, de->d_name) && len > 5 && !strcmp(&de->d_name[len - 5], ".conf")) { char *filename = strdupz_path_subpath(udir, de->d_name); - debug(D_HEALTH, "CONFIG calling callback for user file '%s'", filename); + netdata_log_debug(D_HEALTH, "CONFIG calling callback for user file '%s'", filename); callback(filename, data); freez(filename); continue; } } - debug(D_HEALTH, "CONFIG ignoring user-config file '%s/%s' of type %d", udir, de->d_name, (int)de->d_type); + netdata_log_debug(D_HEALTH, "CONFIG ignoring user-config file '%s/%s' of type %d", udir, de->d_name, (int)de->d_type); } closedir(dir); } - debug(D_HEALTH, "CONFIG traversing stock config directory '%s', user config directory '%s'", sdir, udir); + netdata_log_debug(D_HEALTH, "CONFIG traversing stock config directory '%s', user config directory '%s'", sdir, udir); dir = opendir(sdir); if (!dir) { @@ -1586,7 +1586,7 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p (de->d_name[0] == '.' && de->d_name[1] == '\0') || (de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0') ) { - debug(D_HEALTH, "CONFIG ignoring stock config directory '%s/%s'", sdir, de->d_name); + netdata_log_debug(D_HEALTH, "CONFIG ignoring stock config directory '%s/%s'", sdir, de->d_name); continue; } @@ -1606,7 +1606,7 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p if(path_is_file(sdir, de->d_name) && !path_is_file(udir, de->d_name) && len > 5 && !strcmp(&de->d_name[len - 5], ".conf")) { char *filename = strdupz_path_subpath(sdir, de->d_name); - debug(D_HEALTH, "CONFIG calling callback for stock file '%s'", filename); + netdata_log_debug(D_HEALTH, "CONFIG calling callback for stock file '%s'", filename); callback(filename, data); freez(filename); continue; @@ -1614,13 +1614,13 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p } - debug(D_HEALTH, "CONFIG ignoring stock-config file '%s/%s' of type %d", udir, de->d_name, (int)de->d_type); + netdata_log_debug(D_HEALTH, "CONFIG ignoring stock-config file '%s/%s' of type %d", udir, de->d_name, (int)de->d_type); } } closedir(dir); } - debug(D_HEALTH, "CONFIG done traversing user-config directory '%s', stock config directory '%s'", udir, sdir); + netdata_log_debug(D_HEALTH, "CONFIG done traversing user-config directory '%s', stock config directory '%s'", udir, sdir); freez(udir); freez(sdir); diff --git a/libnetdata/locks/locks.c b/libnetdata/locks/locks.c index 7c806688d9..625dd052ce 100644 --- a/libnetdata/locks/locks.c +++ b/libnetdata/locks/locks.c @@ -135,29 +135,29 @@ int __netdata_mutex_unlock(netdata_mutex_t *mutex) { int netdata_mutex_init_debug(const char *file __maybe_unused, const char *function __maybe_unused, const unsigned long line __maybe_unused, netdata_mutex_t *mutex) { - debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_init(%p) from %lu@%s, %s()", mutex, line, file, function); + netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_init(%p) from %lu@%s, %s()", mutex, line, file, function); int ret = __netdata_mutex_init(mutex); - debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_init(%p) = %d, from %lu@%s, %s()", mutex, ret, line, file, function); + netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_init(%p) = %d, from %lu@%s, %s()", mutex, ret, line, file, function); return ret; } int netdata_mutex_destroy_debug(const char *file __maybe_unused, const char *function __maybe_unused, const unsigned long line __maybe_unused, netdata_mutex_t *mutex) { - debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_destroy(%p) from %lu@%s, %s()", mutex, line, file, function); + netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_destroy(%p) from %lu@%s, %s()", mutex, line, file, function); int ret = __netdata_mutex_destroy(mutex); - debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_destroy(%p) = %d, from %lu@%s, %s()", mutex, ret, line, file, function); + netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_destroy(%p) = %d, from %lu@%s, %s()", mutex, ret, line, file, function); return ret; } int netdata_mutex_lock_debug(const char *file __maybe_unused, const char *function __maybe_unused, const unsigned long line __maybe_unused, netdata_mutex_t *mutex) { - debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_lock(%p) from %lu@%s, %s()", mutex, line, file, function); + netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_lock(%p) from %lu@%s, %s()", mutex, line, file, function); usec_t start_s = now_monotonic_high_precision_usec(); int ret = __netdata_mutex_lock(mutex); @@ -167,14 +167,14 @@ int netdata_mutex_lock_debug(const char *file __maybe_unused, const char *functi (void)start_s; (void)end_s; - debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_lock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function); + netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_lock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function); return ret; } int netdata_mutex_trylock_debug(const char *file __maybe_unused, const char *function __maybe_unused, const unsigned long line __maybe_unused, netdata_mutex_t *mutex) { - debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_trylock(%p) from %lu@%s, %s()", mutex, line, file, function); + netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_trylock(%p) from %lu@%s, %s()", mutex, line, file, function); usec_t start_s = now_monotonic_high_precision_usec(); int ret = __netdata_mutex_trylock(mutex); @@ -184,14 +184,14 @@ int netdata_mutex_trylock_debug(const char *file __maybe_unused, const char *fun (void)start_s; (void)end_s; - debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_trylock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function); + netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_trylock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function); return ret; } int netdata_mutex_unlock_debug(const char *file __maybe_unused, const char *function __maybe_unused, const unsigned long line __maybe_unused, netdata_mutex_t *mutex) { - debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_unlock(%p) from %lu@%s, %s()", mutex, line, file, function); + netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_unlock(%p) from %lu@%s, %s()", mutex, line, file, function); usec_t start_s = now_monotonic_high_precision_usec(); int ret = __netdata_mutex_unlock(mutex); @@ -201,7 +201,7 @@ int netdata_mutex_unlock_debug(const char *file __maybe_unused, const char *func (void)start_s; (void)end_s; - debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_unlock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function); + netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_unlock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function); return ret; } diff --git a/libnetdata/log/log.h b/libnetdata/log/log.h index 53de391d54..22be73d893 100644 --- a/libnetdata/log/log.h +++ b/libnetdata/log/log.h @@ -109,11 +109,11 @@ typedef struct error_with_limit { #define error_limit_static_thread_var(var, log_every_secs, sleep_usecs) static __thread ERROR_LIMIT var = { .last_logged = 0, .count = 0, .log_every = (log_every_secs), .sleep_ut = (sleep_usecs) } #ifdef NETDATA_INTERNAL_CHECKS -#define debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0) +#define netdata_log_debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0) #define internal_error(condition, args...) do { if(unlikely(condition)) error_int(0, "IERR", __FILE__, __FUNCTION__, __LINE__, ##args); } while(0) #define internal_fatal(condition, args...) do { if(unlikely(condition)) fatal_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0) #else -#define debug(type, args...) debug_dummy() +#define netdata_log_debug(type, args...) debug_dummy() #define internal_error(args...) debug_dummy() #define internal_fatal(args...) debug_dummy() #endif diff --git a/libnetdata/os.c b/libnetdata/os.c index f0e2411720..e6475a453f 100644 --- a/libnetdata/os.c +++ b/libnetdata/os.c @@ -75,7 +75,7 @@ long get_system_cpus_with_cache(bool cache, bool for_netdata) { if(processors[index] < 1) processors[index] = 1; - debug(D_SYSTEM, "System has %ld processors.", processors[index]); + netdata_log_debug(D_SYSTEM, "System has %ld processors.", processors[index]); return processors[index]; #endif /* __APPLE__, __FreeBSD__ */ diff --git a/libnetdata/popen/popen.c b/libnetdata/popen/popen.c index 48e01056f2..5f8bd2b4a6 100644 --- a/libnetdata/popen/popen.c +++ b/libnetdata/popen/popen.c @@ -384,7 +384,7 @@ int netdata_pclose(FILE *fp_child_input, FILE *fp_child_output, pid_t pid) { int ret; siginfo_t info; - debug(D_EXIT, "Request to netdata_pclose() on pid %d", pid); + netdata_log_debug(D_EXIT, "Request to netdata_pclose() on pid %d", pid); if (fp_child_input) fclose(fp_child_input); diff --git a/libnetdata/procfile/procfile.c b/libnetdata/procfile/procfile.c index dd572e0e7e..1a7e47a56a 100644 --- a/libnetdata/procfile/procfile.c +++ b/libnetdata/procfile/procfile.c @@ -48,11 +48,11 @@ char *procfile_filename(procfile *ff) { // An array of words static inline void procfile_words_add(procfile *ff, char *str) { - // debug(D_PROCFILE, PF_PREFIX ": adding word No %d: '%s'", fw->len, str); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": adding word No %d: '%s'", fw->len, str); pfwords *fw = ff->words; if(unlikely(fw->len == fw->size)) { - // debug(D_PROCFILE, PF_PREFIX ": expanding words"); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": expanding words"); size_t minimum = PFWORDS_INCREASE_STEP; size_t optimal = fw->size / 2; size_t wanted = (optimal > minimum)?optimal:minimum; @@ -66,7 +66,7 @@ static inline void procfile_words_add(procfile *ff, char *str) { NEVERNULL static inline pfwords *procfile_words_create(void) { - // debug(D_PROCFILE, PF_PREFIX ": initializing words"); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": initializing words"); size_t size = (procfile_adaptive_initial_allocation) ? procfile_max_words : PFWORDS_INCREASE_STEP; @@ -77,12 +77,12 @@ static inline pfwords *procfile_words_create(void) { } static inline void procfile_words_reset(pfwords *fw) { - // debug(D_PROCFILE, PF_PREFIX ": resetting words"); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": resetting words"); fw->len = 0; } static inline void procfile_words_free(pfwords *fw) { - // debug(D_PROCFILE, PF_PREFIX ": freeing words"); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": freeing words"); freez(fw); } @@ -93,11 +93,11 @@ static inline void procfile_words_free(pfwords *fw) { NEVERNULL static inline size_t *procfile_lines_add(procfile *ff) { - // debug(D_PROCFILE, PF_PREFIX ": adding line %d at word %d", fl->len, first_word); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": adding line %d at word %d", fl->len, first_word); pflines *fl = ff->lines; if(unlikely(fl->len == fl->size)) { - // debug(D_PROCFILE, PF_PREFIX ": expanding lines"); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": expanding lines"); size_t minimum = PFLINES_INCREASE_STEP; size_t optimal = fl->size / 2; size_t wanted = (optimal > minimum)?optimal:minimum; @@ -115,7 +115,7 @@ static inline size_t *procfile_lines_add(procfile *ff) { NEVERNULL static inline pflines *procfile_lines_create(void) { - // debug(D_PROCFILE, PF_PREFIX ": initializing lines"); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": initializing lines"); size_t size = (unlikely(procfile_adaptive_initial_allocation)) ? procfile_max_words : PFLINES_INCREASE_STEP; @@ -126,13 +126,13 @@ static inline pflines *procfile_lines_create(void) { } static inline void procfile_lines_reset(pflines *fl) { - // debug(D_PROCFILE, PF_PREFIX ": resetting lines"); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": resetting lines"); fl->len = 0; } static inline void procfile_lines_free(pflines *fl) { - // debug(D_PROCFILE, PF_PREFIX ": freeing lines"); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": freeing lines"); freez(fl); } @@ -144,7 +144,7 @@ static inline void procfile_lines_free(pflines *fl) { void procfile_close(procfile *ff) { if(unlikely(!ff)) return; - debug(D_PROCFILE, PF_PREFIX ": Closing file '%s'", procfile_filename(ff)); + netdata_log_debug(D_PROCFILE, PF_PREFIX ": Closing file '%s'", procfile_filename(ff)); freez(ff->filename); procfile_lines_free(ff->lines); @@ -156,7 +156,7 @@ void procfile_close(procfile *ff) { NOINLINE static void procfile_parser(procfile *ff) { - // debug(D_PROCFILE, PF_PREFIX ": Parsing file '%s'", ff->filename); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": Parsing file '%s'", ff->filename); char *s = ff->data // our current position , *e = &ff->data[ff->len] // the terminating null @@ -206,7 +206,7 @@ static void procfile_parser(procfile *ff) { (*line_words)++; t = ++s; - // debug(D_PROCFILE, PF_PREFIX ": ended line %d with %d words", l, ff->lines->lines[l].words); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": ended line %d with %d words", l, ff->lines->lines[l].words); line_words = procfile_lines_add(ff); } @@ -275,7 +275,7 @@ static void procfile_parser(procfile *ff) { } procfile *procfile_readall(procfile *ff) { - // debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename); + // netdata_log_debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename); ff->len = 0; // zero the used size ssize_t r = 1; // read at least once @@ -288,12 +288,12 @@ procfile *procfile_readall(procfile *ff) { size_t optimal = ff->size / 2; size_t wanted = (optimal > minimum)?optimal:minimum; - debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s' by %zu bytes.", procfile_filename(ff), wanted); + netdata_log_debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s' by %zu bytes.", procfile_filename(ff), wanted); ff = reallocz(ff, sizeof(procfile) + ff->size + wanted); ff->size += wanted; } - debug(D_PROCFILE, "Reading file '%s', from position %zd with length %zd", procfile_filename(ff), s, (ssize_t)(ff->size - s)); + netdata_log_debug(D_PROCFILE, "Reading file '%s', from position %zd with length %zd", procfile_filename(ff), s, (ssize_t)(ff->size - s)); r = read(ff->fd, &ff->data[s], ff->size - s); if(unlikely(r == -1)) { if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) collector_error(PF_PREFIX ": Cannot read from file '%s' on fd %d", procfile_filename(ff), ff->fd); @@ -306,7 +306,7 @@ procfile *procfile_readall(procfile *ff) { ff->len += r; } - // debug(D_PROCFILE, "Rewinding file '%s'", ff->filename); + // netdata_log_debug(D_PROCFILE, "Rewinding file '%s'", ff->filename); if(unlikely(lseek(ff->fd, 0, SEEK_SET) == -1)) { if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) collector_error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff)); else if(unlikely(ff->flags & PROCFILE_FLAG_ERROR_ON_ERROR_LOG)) @@ -325,7 +325,7 @@ procfile *procfile_readall(procfile *ff) { if(unlikely(ff->words->len > procfile_max_words)) procfile_max_words = ff->words->len; } - // debug(D_PROCFILE, "File '%s' updated.", ff->filename); + // netdata_log_debug(D_PROCFILE, "File '%s' updated.", ff->filename); return ff; } @@ -403,7 +403,7 @@ void procfile_set_open_close(procfile *ff, const char *open, const char *close) } procfile *procfile_open(const char *filename, const char *separators, uint32_t flags) { - debug(D_PROCFILE, PF_PREFIX ": Opening file '%s'", filename); + netdata_log_debug(D_PROCFILE, PF_PREFIX ": Opening file '%s'", filename); int fd = open(filename, procfile_open_flags, 0666); if(unlikely(fd == -1)) { @@ -430,7 +430,7 @@ procfile *procfile_open(const char *filename, const char *separators, uint32_t f procfile_set_separators(ff, separators); - debug(D_PROCFILE, "File '%s' opened.", filename); + netdata_log_debug(D_PROCFILE, "File '%s' opened.", filename); return ff; } @@ -469,17 +469,17 @@ void procfile_print(procfile *ff) { char *s; (void)s; - debug(D_PROCFILE, "File '%s' with %zu lines and %zu words", procfile_filename(ff), ff->lines->len, ff->words->len); + netdata_log_debug(D_PROCFILE, "File '%s' with %zu lines and %zu words", procfile_filename(ff), ff->lines->len, ff->words->len); for(l = 0; likely(l < lines) ;l++) { size_t words = procfile_linewords(ff, l); - debug(D_PROCFILE, " line %zu starts at word %zu and has %zu words", l, ff->lines->lines[l].first, ff->lines->lines[l].words); + netdata_log_debug(D_PROCFILE, " line %zu starts at word %zu and has %zu words", l, ff->lines->lines[l].first, ff->lines->lines[l].words); size_t w; for(w = 0; likely(w < words) ;w++) { s = procfile_lineword(ff, l, w); - debug(D_PROCFILE, " [%zu.%zu] '%s'", l, w, s); + netdata_log_debug(D_PROCFILE, " [%zu.%zu] '%s'", l, w, s); } } } diff --git a/libnetdata/simple_pattern/simple_pattern.c b/libnetdata/simple_pattern/simple_pattern.c index a26ae4f920..70bde73a6c 100644 --- a/libnetdata/simple_pattern/simple_pattern.c +++ b/libnetdata/simple_pattern/simple_pattern.c @@ -326,10 +326,10 @@ extern void simple_pattern_dump(uint64_t debug_type, SIMPLE_PATTERN *p) { struct simple_pattern *root = (struct simple_pattern *)p; if(root==NULL) { - debug(debug_type,"dump_pattern(NULL)"); + netdata_log_debug(debug_type,"dump_pattern(NULL)"); return; } - debug(debug_type,"dump_pattern(%p) child=%p next=%p mode=%u match=%s", root, root->child, root->next, root->mode, + netdata_log_debug(debug_type,"dump_pattern(%p) child=%p next=%p mode=%u match=%s", root, root->child, root->next, root->mode, root->match); if(root->child!=NULL) simple_pattern_dump(debug_type, (SIMPLE_PATTERN*)root->child); diff --git a/libnetdata/socket/security.c b/libnetdata/socket/security.c index 56cb29330a..c1bb763456 100644 --- a/libnetdata/socket/security.c +++ b/libnetdata/socket/security.c @@ -406,7 +406,7 @@ bool netdata_ssl_accept(NETDATA_SSL *ssl) { static void netdata_ssl_info_callback(const SSL *ssl, int where, int ret __maybe_unused) { (void)ssl; if (where & SSL_CB_ALERT) { - debug(D_WEB_CLIENT,"SSL INFO CALLBACK %s %s", SSL_alert_type_string(ret), SSL_alert_desc_string_long(ret)); + netdata_log_debug(D_WEB_CLIENT,"SSL INFO CALLBACK %s %s", SSL_alert_type_string(ret), SSL_alert_desc_string_long(ret)); } } @@ -559,7 +559,7 @@ static SSL_CTX * netdata_ssl_create_server_ctx(unsigned long mode) { #if (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_095) SSL_CTX_set_verify_depth(ctx,1); #endif - debug(D_WEB_CLIENT,"SSL GLOBAL CONTEXT STARTED\n"); + netdata_log_debug(D_WEB_CLIENT,"SSL GLOBAL CONTEXT STARTED\n"); SSL_CTX_set_mode(ctx, mode); diff --git a/libnetdata/socket/socket.c b/libnetdata/socket/socket.c index 5bcb06834d..e7d0b48076 100644 --- a/libnetdata/socket/socket.c +++ b/libnetdata/socket/socket.c @@ -216,7 +216,7 @@ char *strdup_client_description(int family, const char *protocol, const char *ip int create_listen_socket_unix(const char *path, int listen_backlog) { int sock; - debug(D_LISTENER, "LISTENER: UNIX creating new listening socket on path '%s'", path); + netdata_log_debug(D_LISTENER, "LISTENER: UNIX creating new listening socket on path '%s'", path); sock = socket(AF_UNIX, SOCK_STREAM, 0); if(sock < 0) { @@ -253,14 +253,14 @@ int create_listen_socket_unix(const char *path, int listen_backlog) { return -1; } - debug(D_LISTENER, "LISTENER: Listening on UNIX path '%s'", path); + netdata_log_debug(D_LISTENER, "LISTENER: Listening on UNIX path '%s'", path); return sock; } int create_listen_socket4(int socktype, const char *ip, uint16_t port, int listen_backlog) { int sock; - debug(D_LISTENER, "LISTENER: IPv4 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype); + netdata_log_debug(D_LISTENER, "LISTENER: IPv4 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype); sock = socket(AF_INET, socktype, 0); if(sock < 0) { @@ -297,7 +297,7 @@ int create_listen_socket4(int socktype, const char *ip, uint16_t port, int liste return -1; } - debug(D_LISTENER, "LISTENER: Listening on IPv4 ip '%s' port %d, socktype %d", ip, port, socktype); + netdata_log_debug(D_LISTENER, "LISTENER: Listening on IPv4 ip '%s' port %d, socktype %d", ip, port, socktype); return sock; } @@ -305,7 +305,7 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p int sock; int ipv6only = 1; - debug(D_LISTENER, "LISTENER: IPv6 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype); + netdata_log_debug(D_LISTENER, "LISTENER: IPv6 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype); sock = socket(AF_INET6, socktype, 0); if (sock < 0) { @@ -349,7 +349,7 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p return -1; } - debug(D_LISTENER, "LISTENER: Listening on IPv6 ip '%s' port %d, socktype %d", ip, port, socktype); + netdata_log_debug(D_LISTENER, "LISTENER: Listening on IPv6 ip '%s' port %d, socktype %d", ip, port, socktype); return sock; } @@ -603,7 +603,7 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition, } default: - debug(D_LISTENER, "LISTENER: Unknown socket family %d", family); + netdata_log_debug(D_LISTENER, "LISTENER: Unknown socket family %d", family); break; } @@ -635,7 +635,7 @@ int listen_sockets_setup(LISTEN_SOCKETS *sockets) { } else sockets->default_port = (uint16_t)new_port; - debug(D_OPTIONS, "LISTENER: Default listen port set to %d.", sockets->default_port); + netdata_log_debug(D_OPTIONS, "LISTENER: Default listen port set to %d.", sockets->default_port); char *s = appconfig_get(sockets->config, sockets->config_section, "bind to", sockets->default_bind_to); while(*s) { @@ -697,7 +697,7 @@ static inline int connect_to_unix(const char *path, struct timeval *timeout) { return -1; } - debug(D_CONNECT_TO, "Connected to UNIX socket on path '%s'.", path); + netdata_log_debug(D_CONNECT_TO, "Connected to UNIX socket on path '%s'.", path); return fd; } @@ -748,7 +748,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t sizeof(servBfr), NI_NUMERICHOST | NI_NUMERICSERV); - debug(D_CONNECT_TO, "Address info: host = '%s', service = '%s', ai_flags = 0x%02X, ai_family = %d (PF_INET = %d, PF_INET6 = %d), ai_socktype = %d (SOCK_STREAM = %d, SOCK_DGRAM = %d), ai_protocol = %d (IPPROTO_TCP = %d, IPPROTO_UDP = %d), ai_addrlen = %lu (sockaddr_in = %lu, sockaddr_in6 = %lu)", + netdata_log_debug(D_CONNECT_TO, "Address info: host = '%s', service = '%s', ai_flags = 0x%02X, ai_family = %d (PF_INET = %d, PF_INET6 = %d), ai_socktype = %d (SOCK_STREAM = %d, SOCK_DGRAM = %d), ai_protocol = %d (IPPROTO_TCP = %d, IPPROTO_UDP = %d), ai_addrlen = %lu (sockaddr_in = %lu, sockaddr_in6 = %lu)", hostBfr, servBfr, (unsigned int)ai->ai_flags, @@ -770,7 +770,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t struct sockaddr_in *pSadrIn = (struct sockaddr_in *)ai->ai_addr; (void)pSadrIn; - debug(D_CONNECT_TO, "ai_addr = sin_family: %d (AF_INET = %d, AF_INET6 = %d), sin_addr: '%s', sin_port: '%s'", + netdata_log_debug(D_CONNECT_TO, "ai_addr = sin_family: %d (AF_INET = %d, AF_INET6 = %d), sin_addr: '%s', sin_port: '%s'", pSadrIn->sin_family, AF_INET, AF_INET6, @@ -783,7 +783,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t struct sockaddr_in6 *pSadrIn6 = (struct sockaddr_in6 *) ai->ai_addr; (void)pSadrIn6; - debug(D_CONNECT_TO,"ai_addr = sin6_family: %d (AF_INET = %d, AF_INET6 = %d), sin6_addr: '%s', sin6_port: '%s', sin6_flowinfo: %u, sin6_scope_id: %u", + netdata_log_debug(D_CONNECT_TO,"ai_addr = sin6_family: %d (AF_INET = %d, AF_INET6 = %d), sin6_addr: '%s', sin6_port: '%s', sin6_flowinfo: %u, sin6_scope_id: %u", pSadrIn6->sin6_family, AF_INET, AF_INET6, @@ -795,7 +795,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t } default: { - debug(D_CONNECT_TO, "Unknown protocol family %d.", ai->ai_family); + netdata_log_debug(D_CONNECT_TO, "Unknown protocol family %d.", ai->ai_family); continue; } } @@ -854,7 +854,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t } if(fd != -1) - debug(D_CONNECT_TO, "Connected to '%s' on port '%s'.", hostBfr, servBfr); + netdata_log_debug(D_CONNECT_TO, "Connected to '%s' on port '%s'.", hostBfr, servBfr); } } @@ -930,7 +930,7 @@ int connect_to_this(const char *definition, int default_port, struct timeval *ti service = e; } - debug(D_CONNECT_TO, "Attempting connection to host = '%s', service = '%s', interface = '%s', protocol = %d (tcp = %d, udp = %d)", host, service, interface, protocol, IPPROTO_TCP, IPPROTO_UDP); + netdata_log_debug(D_CONNECT_TO, "Attempting connection to host = '%s', service = '%s', interface = '%s', protocol = %d (tcp = %d, udp = %d)", host, service, interface, protocol, IPPROTO_TCP, IPPROTO_UDP); if(!*host) { netdata_log_error("Definition '%s' does not specify a host.", definition); @@ -1189,7 +1189,7 @@ int accept4(int sock, struct sockaddr *addr, socklen_t *addrlen, int flags) { int connection_allowed(int fd, char *client_ip, char *client_host, size_t hostsize, SIMPLE_PATTERN *access_list, const char *patname, int allow_dns) { - debug(D_LISTENER,"checking %s... (allow_dns=%d)", patname, allow_dns); + netdata_log_debug(D_LISTENER,"checking %s... (allow_dns=%d)", patname, allow_dns); if (!access_list) return 1; if (simple_pattern_matches(access_list, client_ip)) @@ -1231,7 +1231,7 @@ int connection_allowed(int fd, char *client_ip, char *client_host, size_t hostsi inet_ntop(AF_INET6, &((struct sockaddr_in6*)(scan->ai_addr))->sin6_addr, address, INET6_ADDRSTRLEN); break; } - debug(D_LISTENER, "Incoming ip %s rev-resolved onto %s, validating against forward-resolution %s", + netdata_log_debug(D_LISTENER, "Incoming ip %s rev-resolved onto %s, validating against forward-resolution %s", client_ip, client_host, address); if (!strcmp(client_ip, address)) { validated = 1; @@ -1248,7 +1248,7 @@ int connection_allowed(int fd, char *client_ip, char *client_host, size_t hostsi freeaddrinfo(addr_infos); } if (!simple_pattern_matches(access_list, client_host)) { - debug(D_LISTENER, "Incoming connection on '%s' (%s) does not match allowed pattern for %s", + netdata_log_debug(D_LISTENER, "Incoming connection on '%s' (%s) does not match allowed pattern for %s", client_ip, client_host, patname); return 0; } @@ -1284,26 +1284,26 @@ int accept_socket(int fd, int flags, char *client_ip, size_t ipsize, char *clien switch (((struct sockaddr *)&sadr)->sa_family) { case AF_UNIX: - debug(D_LISTENER, "New UNIX domain web client from %s on socket %d.", client_ip, fd); + netdata_log_debug(D_LISTENER, "New UNIX domain web client from %s on socket %d.", client_ip, fd); // set the port - certain versions of libc return garbage on unix sockets strncpyz(client_port, "UNIX", portsize); break; case AF_INET: - debug(D_LISTENER, "New IPv4 web client from %s port %s on socket %d.", client_ip, client_port, fd); + netdata_log_debug(D_LISTENER, "New IPv4 web client from %s port %s on socket %d.", client_ip, client_port, fd); break; case AF_INET6: if (strncmp(client_ip, "::ffff:", 7) == 0) { memmove(client_ip, &client_ip[7], strlen(&client_ip[7]) + 1); - debug(D_LISTENER, "New IPv4 web client from %s port %s on socket %d.", client_ip, client_port, fd); + netdata_log_debug(D_LISTENER, "New IPv4 web client from %s port %s on socket %d.", client_ip, client_port, fd); } else - debug(D_LISTENER, "New IPv6 web client from %s port %s on socket %d.", client_ip, client_port, fd); + netdata_log_debug(D_LISTENER, "New IPv6 web client from %s port %s on socket %d.", client_ip, client_port, fd); break; default: - debug(D_LISTENER, "New UNKNOWN web client from %s port %s on socket %d.", client_ip, client_port, fd); + netdata_log_debug(D_LISTENER, "New UNKNOWN web client from %s port %s on socket %d.", client_ip, client_port, fd); break; } if (!connection_allowed(nfd, client_ip, client_host, hostsize, access_list, "connection", allow_dns)) { @@ -1344,7 +1344,7 @@ inline POLLINFO *poll_add_fd(POLLJOB *p , int (*snd_callback)(POLLINFO * /*pi*/, short int * /*events*/) , void *data ) { - debug(D_POLLFD, "POLLFD: ADD: request to add fd %d, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", fd, p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); + netdata_log_debug(D_POLLFD, "POLLFD: ADD: request to add fd %d, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", fd, p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); if(unlikely(fd < 0)) return NULL; @@ -1356,7 +1356,7 @@ inline POLLINFO *poll_add_fd(POLLJOB *p if(unlikely(!p->first_free)) { size_t new_slots = p->slots + POLL_FDS_INCREASE_STEP; - debug(D_POLLFD, "POLLFD: ADD: increasing size (current = %zu, new = %zu, used = %zu, min = %zu, max = %zu)", p->slots, new_slots, p->used, p->min, p->max); + netdata_log_debug(D_POLLFD, "POLLFD: ADD: increasing size (current = %zu, new = %zu, used = %zu, min = %zu, max = %zu)", p->slots, new_slots, p->used, p->min, p->max); p->fds = reallocz(p->fds, sizeof(struct pollfd) * new_slots); p->inf = reallocz(p->inf, sizeof(POLLINFO) * new_slots); @@ -1364,7 +1364,7 @@ inline POLLINFO *poll_add_fd(POLLJOB *p // reset all the newly added slots ssize_t i; for(i = new_slots - 1; i >= (ssize_t)p->slots ; i--) { - debug(D_POLLFD, "POLLFD: ADD: resetting new slot %zd", i); + netdata_log_debug(D_POLLFD, "POLLFD: ADD: resetting new slot %zd", i); p->fds[i].fd = -1; p->fds[i].events = 0; p->fds[i].revents = 0; @@ -1395,7 +1395,7 @@ inline POLLINFO *poll_add_fd(POLLJOB *p POLLINFO *pi = p->first_free; p->first_free = p->first_free->next; - debug(D_POLLFD, "POLLFD: ADD: selected slot %zu, next free is %zd", pi->slot, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); + netdata_log_debug(D_POLLFD, "POLLFD: ADD: selected slot %zu, next free is %zd", pi->slot, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); struct pollfd *pf = &p->fds[pi->slot]; pf->fd = fd; @@ -1437,7 +1437,7 @@ inline POLLINFO *poll_add_fd(POLLJOB *p } netdata_thread_enable_cancelability(); - debug(D_POLLFD, "POLLFD: ADD: completed, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); + netdata_log_debug(D_POLLFD, "POLLFD: ADD: completed, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); return pi; } @@ -1446,7 +1446,7 @@ inline void poll_close_fd(POLLINFO *pi) { POLLJOB *p = pi->p; struct pollfd *pf = &p->fds[pi->slot]; - debug(D_POLLFD, "POLLFD: DEL: request to clear slot %zu (fd %d), old next free was %zd", pi->slot, pf->fd, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); + netdata_log_debug(D_POLLFD, "POLLFD: DEL: request to clear slot %zu (fd %d), old next free was %zd", pi->slot, pf->fd, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); if(unlikely(pf->fd == -1)) return; @@ -1499,7 +1499,7 @@ inline void poll_close_fd(POLLINFO *pi) { } netdata_thread_enable_cancelability(); - debug(D_POLLFD, "POLLFD: DEL: completed, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); + netdata_log_debug(D_POLLFD, "POLLFD: DEL: completed, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); } void *poll_default_add_callback(POLLINFO *pi, short int *events, void *data) { @@ -1586,7 +1586,7 @@ static inline int poll_process_send(POLLJOB *p, POLLINFO *pi, struct pollfd *pf, pi->last_sent_t = now; pi->send_count++; - debug(D_POLLFD, "POLLFD: LISTENER: sending data to socket on slot %zu (fd %d)", pi->slot, pf->fd); + netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: sending data to socket on slot %zu (fd %d)", pi->slot, pf->fd); pf->events = 0; @@ -1607,7 +1607,7 @@ static inline int poll_process_tcp_read(POLLJOB *p, POLLINFO *pi, struct pollfd pi->last_received_t = now; pi->recv_count++; - debug(D_POLLFD, "POLLFD: LISTENER: reading data from TCP client slot %zu (fd %d)", pi->slot, pf->fd); + netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: reading data from TCP client slot %zu (fd %d)", pi->slot, pf->fd); pf->events = 0; @@ -1628,7 +1628,7 @@ static inline int poll_process_udp_read(POLLINFO *pi, struct pollfd *pf, time_t pi->last_received_t = now; pi->recv_count++; - debug(D_POLLFD, "POLLFD: LISTENER: reading data from UDP slot %zu (fd %d)", pi->slot, pf->fd); + netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: reading data from UDP slot %zu (fd %d)", pi->slot, pf->fd); // TODO: access_list is not applied to UDP // but checking the access list on every UDP packet will destroy @@ -1648,13 +1648,13 @@ static int poll_process_new_tcp_connection(POLLJOB *p, POLLINFO *pi, struct poll pi->last_received_t = now; pi->recv_count++; - debug(D_POLLFD, "POLLFD: LISTENER: accepting connections from slot %zu (fd %d)", pi->slot, pf->fd); + netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: accepting connections from slot %zu (fd %d)", pi->slot, pf->fd); char client_ip[INET6_ADDRSTRLEN] = ""; char client_port[NI_MAXSERV] = ""; char client_host[NI_MAXHOST] = ""; - debug(D_POLLFD, "POLLFD: LISTENER: calling accept4() slot %zu (fd %d)", pi->slot, pf->fd); + netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: calling accept4() slot %zu (fd %d)", pi->slot, pf->fd); int nfd = accept_socket( pf->fd,SOCK_NONBLOCK, @@ -1665,7 +1665,7 @@ static int poll_process_new_tcp_connection(POLLJOB *p, POLLINFO *pi, struct poll if (unlikely(nfd < 0)) { // accept failed - debug(D_POLLFD, "POLLFD: LISTENER: accept4() slot %zu (fd %d) failed.", pi->slot, pf->fd); + netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: accept4() slot %zu (fd %d) failed.", pi->slot, pf->fd); if(unlikely(errno == EMFILE)) { error_limit_static_global_var(erl, 10, 1000); @@ -1797,7 +1797,7 @@ void poll_events(LISTEN_SOCKETS *sockets now_usec = now_boottime_usec(); if(unlikely(timer_usec && now_usec >= next_timer_usec)) { - debug(D_POLLFD, "Calling timer callback after %zu usec", (size_t)(now_usec - last_timer_usec)); + netdata_log_debug(D_POLLFD, "Calling timer callback after %zu usec", (size_t)(now_usec - last_timer_usec)); last_timer_usec = now_usec; p.tmr_callback(p.timer_data); now_usec = now_boottime_usec(); @@ -1822,7 +1822,7 @@ void poll_events(LISTEN_SOCKETS *sockets } } - debug(D_POLLFD, "POLLFD: LISTENER: Waiting on %zu sockets for %zu ms...", p.max + 1, (size_t)timeout_ms); + netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: Waiting on %zu sockets for %zu ms...", p.max + 1, (size_t)timeout_ms); retval = poll(p.fds, p.max + 1, timeout_ms); time_t now = now_boottime_sec(); @@ -1831,7 +1831,7 @@ void poll_events(LISTEN_SOCKETS *sockets break; } else if(unlikely(!retval)) { - debug(D_POLLFD, "POLLFD: LISTENER: poll() timeout."); + netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: poll() timeout."); } else { POLLINFO *pi; @@ -1987,5 +1987,5 @@ void poll_events(LISTEN_SOCKETS *sockets } netdata_thread_cleanup_pop(1); - debug(D_POLLFD, "POLLFD: LISTENER: cleanup completed"); + netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: cleanup completed"); } diff --git a/libnetdata/threads/threads.c b/libnetdata/threads/threads.c index 1ec6864477..adce0463c0 100644 --- a/libnetdata/threads/threads.c +++ b/libnetdata/threads/threads.c @@ -133,7 +133,7 @@ size_t netdata_threads_init(void) { if(i != 0) fatal("pthread_attr_getstacksize() failed with code %d.", i); else - debug(D_OPTIONS, "initial pthread stack size is %zu bytes", stacksize); + netdata_log_debug(D_OPTIONS, "initial pthread stack size is %zu bytes", stacksize); return stacksize; } -- cgit v1.2.3