Loading src/common/log.c +24 −2 Original line number Diff line number Diff line Loading @@ -889,6 +889,29 @@ add_temp_log(int min_severity) UNLOCK_LOGS(); } #define CALLBACK_FILENAME "<callback>" /** * Removes the latest log handler added, if that log handler is a callback * handler. */ void remove_log_callback(void) { if(logfiles && !strcmp(logfiles->filename, CALLBACK_FILENAME)) { logfile_t *lf = logfiles; LOCK_LOGS(); logfiles = lf->next; log_global_min_severity_ = get_min_log_level(); UNLOCK_LOGS(); tor_free(lf->filename); tor_free(lf->severities); tor_free(lf); } } /** * Add a log handler to send messages in <b>severity</b> * to the function <b>cb</b>. Loading @@ -900,7 +923,7 @@ add_callback_log(const log_severity_list_t *severity, log_callback cb) lf = tor_malloc_zero(sizeof(logfile_t)); lf->fd = -1; lf->severities = tor_memdup(severity, sizeof(log_severity_list_t)); lf->filename = tor_strdup("<callback>"); lf->filename = tor_strdup(CALLBACK_FILENAME); lf->callback = cb; lf->next = logfiles; Loading Loading @@ -1378,4 +1401,3 @@ truncate_logs(void) } } } src/common/torlog.h +1 −1 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ int add_file_log(const log_severity_list_t *severity, const char *filename, int add_syslog_log(const log_severity_list_t *severity, const char* syslog_identity_tag); #endif void remove_log_callback(void); int add_callback_log(const log_severity_list_t *severity, log_callback cb); void logs_set_domain_logging(int enabled); int get_min_log_level(void); Loading Loading @@ -241,4 +242,3 @@ MOCK_DECL(STATIC void, logv, (int severity, log_domain_mask_t domain, # define TOR_TORLOG_H #endif src/test/test_options.c +1 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,7 @@ test_options_validate(void *arg) "We're a bridge but DirCache is disabled."); clear_log_messages(); remove_log_callback(); return; } Loading Loading
src/common/log.c +24 −2 Original line number Diff line number Diff line Loading @@ -889,6 +889,29 @@ add_temp_log(int min_severity) UNLOCK_LOGS(); } #define CALLBACK_FILENAME "<callback>" /** * Removes the latest log handler added, if that log handler is a callback * handler. */ void remove_log_callback(void) { if(logfiles && !strcmp(logfiles->filename, CALLBACK_FILENAME)) { logfile_t *lf = logfiles; LOCK_LOGS(); logfiles = lf->next; log_global_min_severity_ = get_min_log_level(); UNLOCK_LOGS(); tor_free(lf->filename); tor_free(lf->severities); tor_free(lf); } } /** * Add a log handler to send messages in <b>severity</b> * to the function <b>cb</b>. Loading @@ -900,7 +923,7 @@ add_callback_log(const log_severity_list_t *severity, log_callback cb) lf = tor_malloc_zero(sizeof(logfile_t)); lf->fd = -1; lf->severities = tor_memdup(severity, sizeof(log_severity_list_t)); lf->filename = tor_strdup("<callback>"); lf->filename = tor_strdup(CALLBACK_FILENAME); lf->callback = cb; lf->next = logfiles; Loading Loading @@ -1378,4 +1401,3 @@ truncate_logs(void) } } }
src/common/torlog.h +1 −1 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ int add_file_log(const log_severity_list_t *severity, const char *filename, int add_syslog_log(const log_severity_list_t *severity, const char* syslog_identity_tag); #endif void remove_log_callback(void); int add_callback_log(const log_severity_list_t *severity, log_callback cb); void logs_set_domain_logging(int enabled); int get_min_log_level(void); Loading Loading @@ -241,4 +242,3 @@ MOCK_DECL(STATIC void, logv, (int severity, log_domain_mask_t domain, # define TOR_TORLOG_H #endif
src/test/test_options.c +1 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,7 @@ test_options_validate(void *arg) "We're a bridge but DirCache is disabled."); clear_log_messages(); remove_log_callback(); return; } Loading