aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-12-26 10:51:58 -0500
committerNick Mathewson <nickm@torproject.org>2012-12-26 11:07:11 -0500
commitf269e0f9a51ecc7f22e62bde302afd8574d2f96f (patch)
treebb5e6e17261a5142efc9a939674c0cf9027cdd90 /src/common/util.h
parent127cb39ffcacbcd99633671e92d299ef53bbac46 (diff)
downloadtor-f269e0f9a51ecc7f22e62bde302afd8574d2f96f.tar
tor-f269e0f9a51ecc7f22e62bde302afd8574d2f96f.tar.gz
Wrapper function for the common rate-limited-log pattern.
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h
index fabfdb19f..005a3f37c 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;