]> git.ipfire.org Git - thirdparty/systemd.git/blame - logging.h
volume_id: fix Makefile for parallel make
[thirdparty/systemd.git] / logging.h
CommitLineData
54988802 1/*
3c2081fc 2 * simple logging functions that can be expanded into nothing
54988802 3 *
27b77df4
KS
4 * Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
54988802
KS
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
27b77df4 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
54988802
KS
19 *
20 */
21
22#ifndef LOGGING_H
23#define LOGGING_H
24
6b493a20 25#define err(format, arg...) do { } while (0)
f10fec81
GKH
26#define info(format, arg...) do { } while (0)
27#define dbg(format, arg...) do { } while (0)
7257cb18
KS
28#define logging_init(foo) do { } while (0)
29#define logging_close(foo) do { } while (0)
f10fec81 30
6c18b1fb 31#ifdef USE_LOG
95a6f4c8 32#include <stdarg.h>
e5369f0a 33#include <unistd.h>
54988802 34#include <syslog.h>
f10fec81 35
6b493a20
KS
36#undef err
37#define err(format, arg...) \
38 do { \
c1979c82 39 log_message(LOG_ERR ,"%s: " format ,__FUNCTION__ ,## arg); \
6b493a20
KS
40 } while (0)
41
f10fec81 42#undef info
82ca8890
KS
43#define info(format, arg...) \
44 do { \
c1979c82 45 log_message(LOG_INFO ,"%s: " format ,__FUNCTION__ ,## arg); \
54988802 46 } while (0)
54988802
KS
47
48#ifdef DEBUG
f10fec81 49#undef dbg
82ca8890
KS
50#define dbg(format, arg...) \
51 do { \
6b493a20 52 log_message(LOG_DEBUG ,"%s: " format ,__FUNCTION__ ,## arg); \
54988802 53 } while (0)
54988802
KS
54#endif
55
6b493a20 56extern void log_message(int priority, const char *format, ...)
54988802 57 __attribute__ ((format (printf, 2, 3)));
95a6f4c8 58
7257cb18 59#undef logging_init
82ca8890 60static inline void logging_init(const char *program_name)
95a6f4c8 61{
57d782bf 62 openlog(program_name, LOG_PID | LOG_CONS, LOG_DAEMON);
95a6f4c8
GKH
63}
64
7257cb18
KS
65#undef logging_close
66static inline void logging_close(void)
67{
68 closelog();
69}
70
6c18b1fb 71#endif /* USE_LOG */
54988802
KS
72
73#endif