2 * collectd - src/stderr.c
3 * Copyright (C) 2007 Sebastian Harl
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Sebastian Harl <sh at tokkee.org>
27 static int log_level = LOG_DEBUG;
29 static int log_level = LOG_INFO;
30 #endif /* COLLECT_DEBUG */
32 static const char *config_keys[] =
36 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
38 static int stderr_config (const char *key, const char *value)
40 if (0 == strcasecmp (key, "LogLevel")) {
41 if ((0 == strcasecmp (value, "emerg"))
42 || (0 == strcasecmp (value, "alert"))
43 || (0 == strcasecmp (value, "crit"))
44 || (0 == strcasecmp (value, "err")))
46 else if (0 == strcasecmp (value, "warning"))
47 log_level = LOG_WARNING;
48 else if (0 == strcasecmp (value, "notice"))
49 log_level = LOG_NOTICE;
50 else if (0 == strcasecmp (value, "info"))
53 else if (0 == strcasecmp (value, "debug"))
54 log_level = LOG_DEBUG;
55 #endif /* COLLECT_DEBUG */
63 } /* int stderr_config (const char *, const char *) */
65 static void stderr_log (int severity, const char *msg)
67 if (severity > log_level)
70 fprintf (stderr, "%s\n", msg);
72 } /* void stderr_log (int, const char *) */
74 void module_register (void)
76 plugin_register_config ("stderr", stderr_config,
77 config_keys, config_keys_num);
78 plugin_register_log ("stderr", stderr_log);
80 } /* void module_register (void) */
82 /* vim: set sw=4 ts=4 tw=78 noexpandtab : */