2 logging wrapper for libctdb
4 Copyright (C) Ronnie Sahlberg 2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
23 #include "libctdb_private.h"
25 int ctdb_log_level = LOG_WARNING;
27 void ctdb_do_debug(struct ctdb_connection *ctdb,
28 int severity, const char *format, ...)
33 ctdb->log(ctdb->log_priv, severity, format, ap);
37 /* Convenient log helper. */
38 void ctdb_log_file(FILE *outf, int priority, const char *format, va_list ap)
41 priority == LOG_EMERG ? "EMERG" :
42 priority == LOG_ALERT ? "ALERT" :
43 priority == LOG_CRIT ? "CRIT" :
44 priority == LOG_ERR ? "ERR" :
45 priority == LOG_WARNING ? "WARNING" :
46 priority == LOG_NOTICE ? "NOTICE" :
47 priority == LOG_INFO ? "INFO" :
48 priority == LOG_DEBUG ? "DEBUG" :
49 "Unknown Error Level");
51 vfprintf(outf, format, ap);
52 if (priority == LOG_ERR) {
53 fprintf(outf, " (%s)", strerror(errno));