summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_log_moderation.h
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-01-17 20:00:00 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-01-17 20:00:00 +0300
commit16cbf3c076a0aca6d47adaf3f719493674cf2363 (patch)
treee6530480020f62a2bdbf249988ec3e2a751d3927 /src/nxt_log_moderation.h
downloadunit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.gz
unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.bz2
Initial version.
Diffstat (limited to 'src/nxt_log_moderation.h')
-rw-r--r--src/nxt_log_moderation.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/nxt_log_moderation.h b/src/nxt_log_moderation.h
new file mode 100644
index 00000000..5a794e79
--- /dev/null
+++ b/src/nxt_log_moderation.h
@@ -0,0 +1,40 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) NGINX, Inc.
+ */
+
+#ifndef _NXT_LOG_MODERATION_H_INCLUDED_
+#define _NXT_LOG_MODERATION_H_INCLUDED_
+
+
+typedef struct {
+ uint32_t level;
+ uint32_t limit;
+ const char *msg;
+ nxt_thread_spinlock_t lock;
+ nxt_pid_t pid;
+ nxt_uint_t count;
+ nxt_time_t last;
+ nxt_event_timer_t timer;
+} nxt_log_moderation_t;
+
+
+#define NXT_LOG_MODERATION 0, -1, 0, 0, NXT_EVENT_TIMER
+
+
+#define \
+nxt_log_moderate(_mod, _level, _log, ...) \
+ do { \
+ nxt_log_t *_log_ = _log; \
+ \
+ if (_log_->level >= (_level) && nxt_log_moderate_allow(_mod)) { \
+ _log_->handler(_level, _log_, __VA_ARGS__); \
+ } \
+ } while (0)
+
+
+nxt_bool_t nxt_log_moderate_allow(nxt_log_moderation_t *mod);
+
+
+#endif /* _NXT_LOG_MODERATION_H_INCLUDED_ */