-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathprintlog.c
90 lines (78 loc) · 2.1 KB
/
printlog.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2; c-brace-offset: -2; c-argdecl-indent: 2 -*- */
/* paclink-unix client for the Winlink 2000 ham radio email system.
*
* Copyright 2006 Nicholas S. Castellano <n2qz@arrl.net> and others,
* See the file AUTHORS for a list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef __RCSID
__RCSID("$Id$");
#endif
#if HAVE_STDIO_H
# include <stdio.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#if HAVE_ERRNO_H
# include <errno.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#endif
#include "compat.h"
#include "printlog.h"
/*
* Print an error message to either stderr or syslog.
*
* Messages with priority LOG_DEBUG_VERBOSE will only be printed
* if the global verbose flag is set TRUE.
*/
void
print_log(int priority, const char *fmt, ...)
{
va_list args;
char *sp;
if(priority == LOG_DEBUG_VERBOSE) {
if(!gverbose_flag) {
return;
} else {
priority = LOG_DEBUG;
}
}
va_start(args, fmt);
if (vasprintf(&sp, fmt, args) < 0) {
syslog(LOG_ERR, "vasprintf() - %s", strerror(errno));
va_end(args);
return;
}
#ifdef WL2KAX25_DAEMON
syslog(priority, "%s", sp);
#else
fprintf(stderr, "%s: %s\n", getprogname(), sp);
#endif /* WL2KAX25_DAEMON */
va_end(args);
}