diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-12-26 10:51:58 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-12-26 11:07:11 -0500 |
commit | f269e0f9a51ecc7f22e62bde302afd8574d2f96f (patch) | |
tree | bb5e6e17261a5142efc9a939674c0cf9027cdd90 /src/common/util.h | |
parent | 127cb39ffcacbcd99633671e92d299ef53bbac46 (diff) | |
download | tor-f269e0f9a51ecc7f22e62bde302afd8574d2f96f.tar.gz tor-f269e0f9a51ecc7f22e62bde302afd8574d2f96f.zip |
Wrapper function for the common rate-limited-log pattern.
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h index fabfdb19fd..005a3f37cd 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -284,6 +284,15 @@ void update_approx_time(time_t now); } } </pre> + + As a convenience wrapper for logging, you can replace the above with: + <pre> + if (possibly_very_frequent_event()) { + static ratelim_t warning_limit = RATELIM_INIT(300); + log_fn_ratelim(&warning_limit, LOG_WARN, LD_GENERAL, + "The event occurred!"); + } + </pre> */ typedef struct ratelim_t { int rate; |