2 * collectd - src/utils_complain.h
3 * Copyright (C) 2006-2013 Florian octo Forster
4 * Copyright (C) 2008 Sebastian tokkee Harl
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; only version 2 of the License is applicable.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Florian octo Forster <octo at verplant.org>
21 * Sebastian tokkee Harl <sh at tokkee.org>
24 #ifndef UTILS_COMPLAIN_H
25 #define UTILS_COMPLAIN_H 1
27 #include "utils_time.h"
31 /* time of the last report */
34 /* How long to wait until reporting again.
35 * 0 indicates that the complaint is no longer valid. */
38 _Bool complained_once;
41 #define C_COMPLAIN_INIT_STATIC { 0, 0, 0 }
42 #define C_COMPLAIN_INIT(c) do { \
45 (c)->complained_once = 0; \
53 * Complain about something. This function will report a message (usually
54 * indicating some error condition) using the collectd logging mechanism.
55 * When this function is called again, reporting the message again will be
56 * deferred by an increasing interval (up to one day) to prevent flooding
57 * the logs. A call to `c_release' resets the counter.
60 * `level' The log level passed to `plugin_log'.
61 * `c' Identifier for the complaint.
62 * `format' Message format - see the documentation of printf(3).
64 void c_complain (int level, c_complain_t *c, const char *format, ...);
71 * Complain about something once. This function will not report anything
72 * again, unless `c_release' has been called in between. If used after some
73 * calls to `c_complain', it will report again on the next interval and stop
76 * See `c_complain' for further details and a description of the parameters.
78 void c_complain_once (int level, c_complain_t *c, const char *format, ...);
85 * Returns true if the specified complaint would be released, false else.
87 #define c_would_release(c) ((c)->interval != 0)
94 * Release a complaint. This will report a message once, marking the
95 * complaint as released.
97 * See `c_complain' for a description of the parameters.
99 void c_do_release (int level, c_complain_t *c, const char *format, ...);
100 #define c_release(level, c, ...) \
102 if (c_would_release (c)) \
103 c_do_release(level, c, __VA_ARGS__); \
106 #endif /* UTILS_COMPLAIN_H */
108 /* vim: set sw=4 ts=4 tw=78 noexpandtab : */