diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-02-21 05:57:12 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-02-21 05:57:12 +0000 |
commit | 0fb179aa2ecbfa2e8c6a2ef287453b123471f8e9 (patch) | |
tree | 5946982409d1de433239aa06ea6a324a480eeaba /src/common/log.h | |
parent | 809a4daa5289ac0751c31690d111f2efef7d26c1 (diff) | |
download | tor-0fb179aa2ecbfa2e8c6a2ef287453b123471f8e9.tar.gz tor-0fb179aa2ecbfa2e8c6a2ef287453b123471f8e9.zip |
r11860@catbus: nickm | 2007-02-21 00:56:15 -0500
Another optimization suggested by Shark output: shave off >90% of uses of logv by cutting down on calls to log_debug when log actually debugging. This is showing up in some profiles bug not others, and might be as much as 2.5%.
svn:r9612
Diffstat (limited to 'src/common/log.h')
-rw-r--r-- | src/common/log.h | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/common/log.h b/src/common/log.h index 78a1bb9ab4..d01305b90a 100644 --- a/src/common/log.h +++ b/src/common/log.h @@ -120,6 +120,8 @@ void _log(int severity, uint32_t domain, const char *format, ...) #define log _log /* hack it so we don't conflict with log() as much */ #ifdef __GNUC__ +extern int _log_global_min_severity; + void _log_fn(int severity, uint32_t domain, const char *funcname, const char *format, ...) CHECK_PRINTF(4,5); @@ -127,8 +129,11 @@ void _log_fn(int severity, uint32_t domain, * of the current function name. */ #define log_fn(severity, domain, args...) \ _log_fn(severity, domain, __PRETTY_FUNCTION__, args) -#define log_debug(domain, args...) \ - _log_fn(LOG_DEBUG, domain, __PRETTY_FUNCTION__, args) +#define log_debug(domain, args...) \ + do { \ + if (PREDICT(_log_global_min_severity == LOG_DEBUG, 0)) \ + _log_fn(LOG_DEBUG, domain, __PRETTY_FUNCTION__, args); \ + } while (0) #define log_info(domain, args...) \ _log_fn(LOG_INFO, domain, __PRETTY_FUNCTION__, args) #define log_notice(domain, args...) \ @@ -155,13 +160,6 @@ void _log_err(uint32_t domain, const char *format, ...); #define log_notice _log_notice #define log_warn _log_warn #define log_err _log_err -/* -#define debug _debug -#define info _info -#define notice _notice -#define warn _warn -#define err _err -*/ #else /* We don't have GCC's varargs macros, so use a global variable to pass the * function name to log_fn */ @@ -175,13 +173,6 @@ extern const char *_log_fn_function_name; #define log_notice (_log_fn_function_name=__func__),_log_notice #define log_warn (_log_fn_function_name=__func__),_log_warn #define log_err (_log_fn_function_name=__func__),_log_err -/* -#define debug (_log_fn_function_name=__func__),_debug -#define info (_log_fn_function_name=__func__),_info -#define notice (_log_fn_function_name=__func__),_notice -#define warn (_log_fn_function_name=__func__),_warn -#define err (_log_fn_function_name=__func__),_err -*/ #endif #endif /* !GNUC */ |