2 * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
4 * This copyrighted material is made available to anyone wishing to use,
5 * modify, copy, or redistribute it subject to the terms and conditions
6 * of the GNU Lesser General Public License v.2.1.
8 * You should have received a copy of the GNU Lesser General Public License
9 * along with this program; if not, write to the Free Software Foundation,
10 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13 #ifndef _LVM_CLOG_LOGGING_H
14 #define _LVM_CLOG_LOGGING_H
17 #define _FILE_OFFSET_BITS 64
19 #include "configure.h"
24 /* SHORT_UUID - print last 8 chars of a string */
25 #define SHORT_UUID(x) (strlen(x) > 8) ? ((x) + (strlen(x) - 8)) : (x)
27 extern const char *__rq_types_off_by_one[];
28 #define RQ_TYPE(x) __rq_types_off_by_one[(x) - 1]
30 extern int log_tabbing;
31 extern int log_is_open;
32 extern int log_membership_change;
33 extern int log_checkpoint;
34 extern int log_resend_requests;
36 #define LOG_OPEN(ident, option, facility) do { \
37 openlog(ident, option, facility); \
41 #define LOG_CLOSE(void) do { \
46 #define LOG_OUTPUT(level, f, arg...) do { \
49 FILE *fp = (level > LOG_NOTICE) ? stderr : stdout; \
51 for (__i = 0; (__i < log_tabbing) && (__i < 15); __i++) \
52 __buffer[__i] = '\t'; \
53 __buffer[__i] = '\0'; \
54 syslog(level, "%s" f "\n", __buffer, ## arg); \
56 for (__i = 0; __i < log_tabbing; __i++) \
58 fprintf(fp, f "\n", ## arg); \
64 #define LOG_DBG(f, arg...) LOG_OUTPUT(LOG_DEBUG, f, ## arg)
66 #define LOG_DBG(f, arg...)
69 #define LOG_COND(__X, f, arg...) do {\
71 LOG_OUTPUT(LOG_NOTICE, f, ## arg); \
74 #define LOG_PRINT(f, arg...) LOG_OUTPUT(LOG_NOTICE, f, ## arg)
75 #define LOG_ERROR(f, arg...) LOG_OUTPUT(LOG_ERR, f, ## arg)
77 #endif /* _LVM_CLOG_LOGGING_H */