]> sourceware.org Git - lvm2.git/blame - lib/log/log.h
dev-type: detect mixed dos partition with gpt's PMBR
[lvm2.git] / lib / log / log.h
CommitLineData
df88dece 1/*
6606c3ae 2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
be684599 3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
df88dece 4 *
6606c3ae
AK
5 * This file is part of LVM2.
6 *
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
be684599 9 * of the GNU Lesser General Public License v.2.1.
6606c3ae 10 *
be684599 11 * You should have received a copy of the GNU Lesser General Public License
6606c3ae 12 * along with this program; if not, write to the Free Software Foundation,
fcbef05a 13 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
df88dece
JT
14 */
15
269930c0
AK
16#ifndef _LVM_LOG_H
17#define _LVM_LOG_H
df88dece 18
4790fce2
AK
19/*
20 * printf()-style macros to use for messages:
21 *
22 * log_error - always print to stderr.
23 * log_print - always print to stdout. Use this instead of printf.
24 * log_verbose - print to stdout if verbose is set (-v)
25 * log_very_verbose - print to stdout if verbose is set twice (-vv)
26 * log_debug - print to stdout if verbose is set three times (-vvv)
4790fce2
AK
27 *
28 * In addition, messages will be logged to file or syslog if they
29 * are more serious than the log level specified with the log/debug_level
30 * parameter in the configuration file. These messages get the file
31 * and line number prepended. 'stack' (without arguments) can be used
32 * to log this information at debug level.
33 *
34 * log_sys_error and log_sys_very_verbose are for errors from system calls
35 * e.g. log_sys_error("stat", filename);
36 * /dev/fd/7: stat failed: No such file or directory
37 *
38 */
39
e6efb2b0 40#include <errno.h>
df88dece 41
c791c54e
AK
42#define EUNCLASSIFIED -1 /* Generic error code */
43
99ea0357
PR
44#define _LOG_FATAL 0x0002
45#define _LOG_ERR 0x0003
46#define _LOG_WARN 0x0004
47#define _LOG_NOTICE 0x0005
48#define _LOG_INFO 0x0006
49#define _LOG_DEBUG 0x0007
50#define _LOG_STDERR 0x0080 /* force things to go to stderr, even if loglevel would make them go to stdout */
51#define _LOG_ONCE 0x0100 /* downgrade to NOTICE if this has been already logged */
52#define _LOG_BYPASS_REPORT 0x0200 /* do not log through report even if report available */
6af26273
ZK
53#define log_level(x) ((x) & 0x0f) /* obtain message level */
54#define log_stderr(x) ((x) & _LOG_STDERR) /* obtain stderr bit */
55#define log_once(x) ((x) & _LOG_ONCE) /* obtain once bit */
56#define log_bypass_report(x) ((x) & _LOG_BYPASS_REPORT)/* obtain bypass bit */
99ea0357 57
550cae23 58#define INTERNAL_ERROR "Internal error: "
df88dece 59
90149c30
DT
60#define LOG_DEBUG_FIELD_ALL 0x0000
61#define LOG_DEBUG_FIELD_TIME 0x0001
62#define LOG_DEBUG_FIELD_COMMAND 0x0002
63#define LOG_DEBUG_FIELD_FILELINE 0x0004
64#define LOG_DEBUG_FIELD_MESSAGE 0x0008
65
bbf8e7db
DT
66#define LOG_JOURNAL_COMMAND 0x0001
67#define LOG_JOURNAL_OUTPUT 0x0002
68#define LOG_JOURNAL_DEBUG 0x0004
69
90149c30 70
7f747a0d
AK
71/*
72 * Classes available for debug log messages.
73 * These are also listed in doc/example.conf
74 * and lib/commands/toolcontext.c:_parse_debug_classes()
75 */
76#define LOG_CLASS_MEM 0x0001 /* "memory" */
77#define LOG_CLASS_DEVS 0x0002 /* "devices" */
78#define LOG_CLASS_ACTIVATION 0x0004 /* "activation" */
79#define LOG_CLASS_ALLOC 0x0008 /* "allocation" */
80#define LOG_CLASS_LVMETAD 0x0010 /* "lvmetad" */
81#define LOG_CLASS_METADATA 0x0020 /* "metadata" */
82#define LOG_CLASS_CACHE 0x0040 /* "cache" */
83#define LOG_CLASS_LOCKING 0x0080 /* "locking" */
c3d351ec 84#define LOG_CLASS_LVMPOLLD 0x0100 /* "lvmpolld" */
2d5dc651 85#define LOG_CLASS_DBUS 0x0200 /* "dbus" */
02e98766 86#define LOG_CLASS_IO 0x0400 /* "io" */
7f747a0d 87
a9cb6969 88#define log_debug(x...) LOG_LINE(_LOG_DEBUG, x)
7f747a0d
AK
89#define log_debug_mem(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_MEM, x)
90#define log_debug_devs(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_DEVS, x)
91#define log_debug_activation(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_ACTIVATION, x)
92#define log_debug_alloc(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_ALLOC, x)
93#define log_debug_lvmetad(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_LVMETAD, x)
94#define log_debug_metadata(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_METADATA, x)
95#define log_debug_cache(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_CACHE, x)
96#define log_debug_locking(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_LOCKING, x)
c3d351ec 97#define log_debug_lvmpolld(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_LVMPOLLD, x)
2d5dc651 98#define log_debug_dbus(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_DBUS, x)
02e98766 99#define log_debug_io(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_IO, x)
7f747a0d 100
a9cb6969
AK
101#define log_info(x...) LOG_LINE(_LOG_INFO, x)
102#define log_notice(x...) LOG_LINE(_LOG_NOTICE, x)
103#define log_warn(x...) LOG_LINE(_LOG_WARN | _LOG_STDERR, x)
b9259173 104#define log_warn_suppress(s, x...) LOG_LINE(s ? _LOG_NOTICE : _LOG_WARN | _LOG_STDERR, x)
c791c54e 105#define log_err(x...) LOG_LINE_WITH_ERRNO(_LOG_ERR, EUNCLASSIFIED, x)
b9259173 106#define log_err_suppress(s, x...) LOG_LINE_WITH_ERRNO(s ? _LOG_NOTICE : _LOG_ERR, EUNCLASSIFIED, x)
9409998d 107#define log_err_once(x...) LOG_LINE_WITH_ERRNO(_LOG_ERR | _LOG_ONCE, EUNCLASSIFIED, x)
c791c54e 108#define log_fatal(x...) LOG_LINE_WITH_ERRNO(_LOG_FATAL, EUNCLASSIFIED, x)
df88dece 109
8d6a8717 110#define stack log_debug("<backtrace>") /* Backtrace on error */
26e7f2e0 111#define log_very_verbose(args...) log_info(args)
84b9ec97 112#define log_verbose(args...) log_notice(args)
a9cb6969 113#define log_print(args...) LOG_LINE(_LOG_WARN, args)
438e0050 114#define log_print_unless_silent(args...) LOG_LINE(silent_mode() ? _LOG_NOTICE : _LOG_WARN, args)
84b9ec97 115#define log_error(args...) log_err(args)
b9259173 116#define log_error_suppress(s, args...) log_err_suppress(s, args)
9409998d 117#define log_error_once(args...) log_err_once(args)
9fac4435 118#define log_errno(args...) LOG_LINE_WITH_ERRNO(_LOG_ERR, args)
df88dece 119
84b9ec97 120/* System call equivalents */
2d9133bb 121#define log_sys_error(x, y) \
28760275 122 log_err("%s%s%s failed: %s", y, *y ? ": " : "", x, strerror(errno))
cf992769 123#define log_sys_error_suppress(s, x, y) \
28760275 124 log_err_suppress(s, "%s%s%s failed: %s", y, *y ? ": " : "", x, strerror(errno))
2d9133bb
AK
125#define log_sys_very_verbose(x, y) \
126 log_info("%s: %s failed: %s", y, x, strerror(errno))
914c9723
AK
127#define log_sys_debug(x, y) \
128 log_debug("%s: %s failed: %s", y, x, strerror(errno))
2d9133bb 129
5f4b2acf
AK
130#define return_0 do { stack; return 0; } while (0)
131#define return_NULL do { stack; return NULL; } while (0)
22672be9 132#define return_false do { stack; return false; } while (0)
f5d06efb
DT
133#define return_EINVALID_CMD_LINE \
134 do { stack; return EINVALID_CMD_LINE; } while (0)
b90450b8 135#define return_ECMD_FAILED do { stack; return ECMD_FAILED; } while (0)
5f4b2acf 136#define goto_out do { stack; goto out; } while (0)
4f2f566b 137#define goto_bad do { stack; goto bad; } while (0)
5f4b2acf 138
df88dece 139#endif
This page took 0.229485 seconds and 6 git commands to generate.