sm
lib
json-c
debug.c
Go to the documentation of this file.
1
/*
2
* $Id: debug.c,v 1.5 2006/01/26 02:16:28 mclark Exp $
3
*
4
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
5
* Michael Clark <michael@metaparadigm.com>
6
*
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.
9
*
10
*/
11
12
#include "config.h"
13
14
#include <stdio.h>
15
#include <stdlib.h>
16
#include <string.h>
17
#include <stdarg.h>
18
19
#if HAVE_SYSLOG_H
20
# include <syslog.h>
21
#endif
/* HAVE_SYSLOG_H */
22
23
#if HAVE_UNISTD_H
24
# include <unistd.h>
25
#endif
/* HAVE_UNISTD_H */
26
27
#if HAVE_SYS_PARAM_H
28
#include <sys/param.h>
29
#endif
/* HAVE_SYS_PARAM_H */
30
31
#include "
debug.h
"
32
33
static
int
_syslog
= 0;
34
static
int
_debug
= 0;
35
36
void
mc_set_debug
(
int
debug
) {
_debug
=
debug
; }
37
int
mc_get_debug
() {
return
_debug
; }
38
39
extern
void
mc_set_syslog
(
int
syslog)
40
{
41
_syslog
= syslog;
42
}
43
44
void
mc_abort
(
const
char
*msg, ...)
45
{
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);
55
}
56
57
58
void
mc_debug
(
const
char
*msg, ...)
59
{
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);
69
}
70
}
71
72
void
mc_error
(
const
char
*msg, ...)
73
{
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);
82
}
83
84
void
mc_info
(
const
char
*msg, ...)
85
{
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);
94
}
_debug
static int _debug
Definition:
debug.c:34
mc_info
void mc_info(const char *msg,...)
Definition:
debug.c:84
mc_debug
void mc_debug(const char *msg,...)
Definition:
debug.c:58
debug
int debug
Definition:
sm2.c:20
mc_abort
void mc_abort(const char *msg,...)
Definition:
debug.c:44
mc_set_debug
void mc_set_debug(int debug)
Definition:
debug.c:36
mc_error
void mc_error(const char *msg,...)
Definition:
debug.c:72
mc_get_debug
int mc_get_debug()
Definition:
debug.c:37
_syslog
static int _syslog
Definition:
debug.c:33
mc_set_syslog
void mc_set_syslog(int syslog)
Definition:
debug.c:39
debug.h
csm
Author(s): Andrea Censi
autogenerated on Wed Aug 17 2022 02:50:33