24#define LOG_WARN LOG_WARNING
25#if LOG_DEBUG < LOG_ERR
27#error "Your syslog.h thinks high numbers are more important. " \
28 "We aren't prepared to deal with that."
62#define LD_GENERAL (UINT64_C(1)<<0)
64#define LD_CRYPTO (UINT64_C(1)<<1)
66#define LD_NET (UINT64_C(1)<<2)
68#define LD_CONFIG (UINT64_C(1)<<3)
70#define LD_FS (UINT64_C(1)<<4)
72#define LD_PROTOCOL (UINT64_C(1)<<5)
74#define LD_MM (UINT64_C(1)<<6)
76#define LD_HTTP (UINT64_C(1)<<7)
78#define LD_APP (UINT64_C(1)<<8)
80#define LD_CONTROL (UINT64_C(1)<<9)
82#define LD_CIRC (UINT64_C(1)<<10)
84#define LD_REND (UINT64_C(1)<<11)
86#define LD_BUG (UINT64_C(1)<<12)
88#define LD_DIR (UINT64_C(1)<<13)
90#define LD_DIRSERV (UINT64_C(1)<<14)
92#define LD_OR (UINT64_C(1)<<15)
94#define LD_EDGE (UINT64_C(1)<<16)
95#define LD_EXIT LD_EDGE
97#define LD_ACCT (UINT64_C(1)<<17)
99#define LD_HIST (UINT64_C(1)<<18)
101#define LD_HANDSHAKE (UINT64_C(1)<<19)
103#define LD_HEARTBEAT (UINT64_C(1)<<20)
105#define LD_CHANNEL (UINT64_C(1)<<21)
107#define LD_SCHED (UINT64_C(1)<<22)
109#define LD_GUARD (UINT64_C(1)<<23)
111#define LD_CONSDIFF (UINT64_C(1)<<24)
113#define LD_DOS (UINT64_C(1)<<25)
115#define LD_PROCESS (UINT64_C(1)<<26)
117#define LD_PT (UINT64_C(1)<<27)
119#define LD_BTRACK (UINT64_C(1)<<28)
121#define LD_MESG (UINT64_C(1)<<29)
124#define N_LOGGING_DOMAINS 30
126#define HIGHEST_RESERVED_LD_DOMAIN_ (UINT64_C(1)<<(N_LOGGING_DOMAINS - 1))
128#define LD_ALL_DOMAINS ((~(UINT64_C(0)))>>(64 - N_LOGGING_DOMAINS))
131#define N_LOGGING_FLAGS 3
133#define LOWEST_RESERVED_LD_FLAG_ (UINT64_C(1)<<(64 - N_LOGGING_FLAGS))
135#define LD_ALL_FLAGS ((~(UINT64_C(0)))<<(64 - N_LOGGING_FLAGS))
139#define LD_NO_MOCK (UINT64_C(1)<<61)
144#define LD_NOCB (UINT64_C(1)<<62)
147#define LD_NOFUNCNAME (UINT64_C(1)<<63)
169 const char *
name,
int fd);
171 const char *filename,
176 const char* syslog_identity_tag);
179typedef void (*pending_callback_callback)(void);
211#define debug_logging_enabled() (1)
224 const char *funcname,
const char *format, ...)
227void log_fn_ratelim_(struct
ratelim_t *ratelim,
int severity,
229 const
char *format, ...)
234 const
char *function, const
char *
string);
236#if defined(__GNUC__) && __GNUC__ <= 3
243#define log_fn(severity, domain, args...) \
244 log_fn_(severity, domain, __FUNCTION__, args)
248#define log_fn_ratelim(ratelim, severity, domain, args...) \
249 log_fn_ratelim_(ratelim, severity, domain, __FUNCTION__, args)
250#define log_debug(domain, args...) \
252 if (debug_logging_enabled()) \
253 log_fn_(LOG_DEBUG, domain, __FUNCTION__, args); \
255#define log_info(domain, args...) \
256 log_fn_(LOG_INFO, domain, __FUNCTION__, args)
257#define log_notice(domain, args...) \
258 log_fn_(LOG_NOTICE, domain, __FUNCTION__, args)
259#define log_warn(domain, args...) \
260 log_fn_(LOG_WARN, domain, __FUNCTION__, args)
261#define log_err(domain, args...) \
262 log_fn_(LOG_ERR, domain, __FUNCTION__, args)
268#define log_debug(domain, args, ...) \
270 if (debug_logging_enabled()) \
271 log_fn_(LOG_DEBUG, domain, __FUNCTION__, args, ##__VA_ARGS__); \
273#define log_info(domain, args,...) \
274 log_fn_(LOG_INFO, domain, __FUNCTION__, args, ##__VA_ARGS__)
275#define log_notice(domain, args,...) \
276 log_fn_(LOG_NOTICE, domain, __FUNCTION__, args, ##__VA_ARGS__)
277#define log_warn(domain, args,...) \
278 log_fn_(LOG_WARN, domain, __FUNCTION__, args, ##__VA_ARGS__)
279#define log_err(domain, args,...) \
280 log_fn_(LOG_ERR, domain, __FUNCTION__, args, ##__VA_ARGS__)
283#define log_fn(severity, domain, args,...) \
284 log_fn_(severity, domain, __FUNCTION__, args, ##__VA_ARGS__)
288#define log_fn_ratelim(ratelim, severity, domain, args,...) \
289 log_fn_ratelim_(ratelim, severity, domain, __FUNCTION__, \
299extern const int LOG_NOTICE_;
305 const char *funcname,
const char *suffix,
const char *format,
306 va_list ap) CHECK_PRINTF(5,0));
311#if defined(LOG_PRIVATE) || defined(TOR_UNIT_TESTS)
314#define SEVERITY_MASK_IDX(sev) ((sev) - LOG_ERR)
Utility macros to handle different features and behavior in different compilers.
STATIC void add_stream_log_impl(const log_severity_list_t *severity, const char *name, int fd)
STATIC void logv(int severity, log_domain_mask_t domain, const char *funcname, const char *suffix, const char *format, va_list ap)
int add_file_log(const log_severity_list_t *severity, const char *filename, int fd)
void tor_log(int severity, log_domain_mask_t domain, const char *format,...)
void init_logging(int disable_startup_queue)
void set_log_severity_config(int minSeverity, int maxSeverity, log_severity_list_t *severity_out)
void flush_log_messages_from_startup(void)
void log_fn_(int severity, log_domain_mask_t domain, const char *funcname, const char *format,...)
void change_callback_log_severity(int loglevelMin, int loglevelMax, log_callback cb)
void mark_logs_temp(void)
void logs_flush_sigsafe(void)
void rollback_log_changes(void)
void logs_set_pending_callback_callback(pending_callback_callback cb)
int add_callback_log(const log_severity_list_t *severity, log_callback cb)
void switch_logs_debug(void)
void tor_log_string(int severity, log_domain_mask_t domain, const char *function, const char *string)
int get_min_log_level(void)
void log_set_application_name(const char *name)
static bool debug_logging_enabled(void)
void set_log_time_granularity(int granularity_msec)
void flush_pending_log_callbacks(void)
int log_message_is_interesting(int severity, log_domain_mask_t domain)
void(* log_callback)(int severity, log_domain_mask_t domain, const char *msg)
int log_global_min_severity_
void tor_log_update_sigsafe_err_fds(void)
int parse_log_severity_config(const char **cfg, log_severity_list_t *severity_out)
const char * log_level_to_string(int level)
void add_stream_log(const log_severity_list_t *severity, const char *name, int fd)
void add_default_log(int min_severity)
void tor_log_get_logfile_names(struct smartlist_t *out)
int parse_log_level(const char *level)
void logs_set_domain_logging(int enabled)
void close_temp_logs(void)
Global definition for types used by logging systems.
uint64_t log_domain_mask_t
log_domain_mask_t masks[LOG_DEBUG-LOG_ERR+1]
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)
Integer definitions used throughout Tor.