2 * collectd - src/utils_complain.h
3 * Copyright (C) 2006-2007 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
31 /* time of the last report */
34 /* how long to wait until reporting again
35 * 0 indicates that the complaint is no longer valid
36 * < 0 indicates that the complaint has been reported once
37 * => c_complain_once will not report again
38 * => c_complain uses the absolute value to reset the old value */
42 #define C_COMPLAIN_INIT_STATIC { 0, 0 }
43 #define C_COMPLAIN_INIT(c) do { (c)->last = 0; (c)->interval = 0; } while (0)
50 * Complain about something. This function will report a message (usually
51 * indicating some error condition) using the collectd logging mechanism.
52 * When this function is called again, reporting the message again will be
53 * deferred by an increasing interval (up to one day) to prevent flooding
54 * the logs. A call to `c_release' resets the counter.
57 * `level' The log level passed to `plugin_log'.
58 * `c' Identifier for the complaint.
59 * `format' Message format - see the documentation of printf(3).
61 void c_complain (int level, c_complain_t *c, const char *format, ...);
68 * Complain about something once. This function will not report anything
69 * again, unless `c_release' has been called in between. If used after some
70 * calls to `c_complain', it will report again on the next interval and stop
73 * See `c_complain' for further details and a description of the parameters.
75 void c_complain_once (int level, c_complain_t *c, const char *format, ...);
82 * Returns true if the specified complaint would be released, false else.
84 #define c_would_release(c) ((c)->interval != 0)
91 * Release a complaint. This will report a message once, marking the
92 * complaint as released.
94 * See `c_complain' for a description of the parameters.
96 void c_do_release (int level, c_complain_t *c, const char *format, ...);
97 #define c_release(level, c, ...) \
99 if (c_would_release (c)) \
100 c_do_release(level, c, __VA_ARGS__); \
103 #endif /* UTILS_COMPLAIN_H */
105 /* vim: set sw=4 ts=4 tw=78 noexpandtab : */