1
/*****************************************************************************/
4
* log.c -- Logging functions.
6
* Copyright (C) 1999-2000 Thomas Sailer (sailer@ife.ee.ethz.ch)
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
* Please note that the GPL allows you to use the driver, NOT the radio.
23
* In order to use the radio, you need a license from the communications
24
* authority of your country.
28
/*****************************************************************************/
43
#include <sys/types.h>
50
/* ---------------------------------------------------------------------- */
52
static unsigned int tosyslog = 0;
53
unsigned int log_verblevel = 0;
55
/* ---------------------------------------------------------------------- */
66
void loginit(unsigned int vl, unsigned int tosysl)
72
openlog("soundmodem", LOG_PID, LOG_DAEMON);
78
void logvprintf(unsigned int level, const char *fmt, va_list args)
80
static const int vltosev[] = { LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE };
82
if (level <= log_verblevel) {
86
vsnprintf(tmp, sizeof(tmp), fmt, args);
87
syslog((level >= 256) ? LOG_DEBUG : (level >= 4) ? LOG_INFO : vltosev[level], tmp);
91
fprintf(stderr, "sm[%lu]: ", (unsigned long)getpid());
92
vfprintf(stderr, fmt, args);
99
void logprintf(unsigned int level, const char *fmt, ...)
104
logvprintf(level, fmt, args);
108
void logerr(unsigned int level, const char *st)
110
logprintf(level, "%s: %s (%d)\n", st, strerror(errno), errno);