]> git.ipfire.org Git - thirdparty/systemd.git/blame - logging.c
[PATCH] man page beauty
[thirdparty/systemd.git] / logging.c
CommitLineData
f0083e3d
GKH
1/*
2 * logging.c
3 *
4 * Simple logging functions that can be compiled away into nothing.
5 *
6 * Copyright (C) 2001-2003 Greg Kroah-Hartman <greg@kroah.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23#include <stdarg.h>
e436917d
OH
24#include <stdio.h>
25#include <sys/types.h>
26#include <unistd.h>
f0083e3d
GKH
27#include <syslog.h>
28#include "udev.h"
29
30#ifdef DEBUG
31
32static int logging_init = 0;
e436917d 33static unsigned char udev_logname[42];
f0083e3d 34
f7b4eca4 35static void init_logging(void)
f0083e3d 36{
f7b4eca4 37 snprintf(udev_logname, 42,"udev[%d]", getpid());
e436917d 38
f7b4eca4 39 openlog(udev_logname, 0, LOG_DAEMON);
f0083e3d
GKH
40 logging_init = 1;
41}
42
43/**
44 * log_message - sends a message to the logging facility
45 */
f7b4eca4 46int log_message(int level, const char *format, ...)
f0083e3d
GKH
47{
48 va_list args;
49
50 if (!logging_init)
51 init_logging();
f7b4eca4
KS
52 va_start(args, format);
53 vsyslog(level, format, args);
54 va_end(args);
f0083e3d
GKH
55 return 1;
56}
57
58#endif