]> git.ipfire.org Git - thirdparty/systemd.git/blame - logging.h
path_id: support SAS devices
[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
6b493a20 27#define err(format, arg...) do { } while (0)
f10fec81
GKH
28#define info(format, arg...) do { } while (0)
29#define dbg(format, arg...) do { } while (0)
7257cb18
KS
30#define logging_init(foo) do { } while (0)
31#define logging_close(foo) do { } while (0)
f10fec81 32
6c18b1fb 33#ifdef USE_LOG
95a6f4c8 34#include <stdarg.h>
e5369f0a 35#include <unistd.h>
54988802 36#include <syslog.h>
f10fec81 37
6b493a20
KS
38#undef err
39#define err(format, arg...) \
40 do { \
c1979c82 41 log_message(LOG_ERR ,"%s: " format ,__FUNCTION__ ,## arg); \
6b493a20
KS
42 } while (0)
43
f10fec81 44#undef info
82ca8890
KS
45#define info(format, arg...) \
46 do { \
c1979c82 47 log_message(LOG_INFO ,"%s: " format ,__FUNCTION__ ,## arg); \
54988802 48 } while (0)
54988802
KS
49
50#ifdef DEBUG
f10fec81 51#undef dbg
82ca8890
KS
52#define dbg(format, arg...) \
53 do { \
6b493a20 54 log_message(LOG_DEBUG ,"%s: " format ,__FUNCTION__ ,## arg); \
54988802 55 } while (0)
54988802
KS
56#endif
57
6b493a20 58extern void log_message(int priority, const char *format, ...)
54988802 59 __attribute__ ((format (printf, 2, 3)));
95a6f4c8 60
7257cb18 61#undef logging_init
82ca8890 62static inline void logging_init(const char *program_name)
95a6f4c8 63{
57d782bf 64 openlog(program_name, LOG_PID | LOG_CONS, LOG_DAEMON);
95a6f4c8
GKH
65}
66
7257cb18
KS
67#undef logging_close
68static inline void logging_close(void)
69{
70 closelog();
71}
72
6c18b1fb 73#endif /* USE_LOG */
54988802
KS
74
75#endif