r23135: inet_ntop and inet_pton are now provided by libreplace
[Samba.git] / source / lib / json / debug.c
blobeaa6fca33c99bdc10437145427eff0c92b6b86a2
1 /*
2 * $Id: debug.c,v 1.5 2006/01/26 02:16:28 mclark Exp $
4 * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
5 * Michael Clark <michael@metaparadigm.com>
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the MIT license. See COPYING for details.
12 #include "config.h"
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include <stdarg.h>
19 #if HAVE_SYSLOG_H
20 # include <syslog.h>
21 #endif /* HAVE_SYSLOG_H */
23 #if HAVE_UNISTD_H
24 # include <unistd.h>
25 #endif /* HAVE_UNISTD_H */
27 #if HAVE_SYS_PARAM_H
28 #include <sys/param.h>
29 #endif /* HAVE_SYS_PARAM_H */
31 #include "debug.h"
33 static int _syslog = 0;
34 static int _debug = 0;
36 void mc_set_debug(int debug) { _debug = debug; }
37 int mc_get_debug() { return _debug; }
39 extern void mc_set_syslog(int syslog)
41 _syslog = syslog;
44 void mc_abort(const char *msg, ...)
46 va_list ap;
47 va_start(ap, msg);
48 #if HAVE_VSYSLOG
49 if(_syslog) {
50 vsyslog(LOG_ERR, msg, ap);
51 } else
52 #endif
53 vprintf(msg, ap);
54 exit(1);
58 void mc_debug(const char *msg, ...)
60 va_list ap;
61 if(_debug) {
62 va_start(ap, msg);
63 #if HAVE_VSYSLOG
64 if(_syslog) {
65 vsyslog(LOG_DEBUG, msg, ap);
66 } else
67 #endif
68 vprintf(msg, ap);
72 void mc_error(const char *msg, ...)
74 va_list ap;
75 va_start(ap, msg);
76 #if HAVE_VSYSLOG
77 if(_syslog) {
78 vsyslog(LOG_ERR, msg, ap);
79 } else
80 #endif
81 vfprintf(stderr, msg, ap);
84 void mc_info(const char *msg, ...)
86 va_list ap;
87 va_start(ap, msg);
88 #if HAVE_VSYSLOG
89 if(_syslog) {
90 vsyslog(LOG_INFO, msg, ap);
91 } else
92 #endif
93 vfprintf(stderr, msg, ap);