]> git.ipfire.org Git - thirdparty/systemd.git/blame - logging.h
[PATCH] switch udev's seqnum to u64
[thirdparty/systemd.git] / logging.h
CommitLineData
54988802 1/*
05230184 2 * logging.h
54988802 3 *
95a6f4c8 4 * Simple logging functions that can be compiled away into nothing.
54988802 5 *
95a6f4c8 6 * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
54988802
KS
7 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
23
24#ifndef LOGGING_H
25#define LOGGING_H
26
f10fec81
GKH
27#define info(format, arg...) do { } while (0)
28#define dbg(format, arg...) do { } while (0)
29#define dbg_parse(format, arg...) do { } while (0)
62e156af 30#define init_logging(foo) do { } while (0)
f10fec81 31
54988802 32#ifdef LOG
95a6f4c8 33#include <stdarg.h>
e5369f0a 34#include <unistd.h>
54988802 35#include <syslog.h>
f10fec81 36
d00bd172
KS
37#define LOGNAME_SIZE 42
38
f10fec81 39#undef info
54988802
KS
40#define info(format, arg...) \
41 do { \
3fe07342 42 log_message(LOG_INFO , format , ## arg); \
54988802 43 } while (0)
54988802
KS
44
45#ifdef DEBUG
f10fec81 46#undef dbg
54988802
KS
47#define dbg(format, arg...) \
48 do { \
3fe07342 49 log_message(LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
54988802 50 } while (0)
54988802
KS
51#endif
52
53/* Parser needs it's own debugging statement, we usually don't care about this at all */
54#ifdef DEBUG_PARSER
f10fec81 55#undef dbg_parse
54988802
KS
56#define dbg_parse(format, arg...) \
57 do { \
3fe07342 58 log_message(LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
54988802 59 } while (0)
54988802
KS
60#endif
61
3fe07342 62extern void log_message(int level, const char *format, ...)
54988802 63 __attribute__ ((format (printf, 2, 3)));
95a6f4c8 64
d026a35d 65/* each program that uses syslog must declare this variable somewhere */
d00bd172 66extern unsigned char logname[LOGNAME_SIZE];
95a6f4c8 67
62e156af 68#undef init_logging
95a6f4c8
GKH
69static inline void init_logging(char *program_name)
70{
d00bd172 71 snprintf(logname, LOGNAME_SIZE,"%s[%d]", program_name, getpid());
95a6f4c8
GKH
72 openlog(logname, 0, LOG_DAEMON);
73}
74
75#endif /* LOG */
54988802
KS
76
77#endif