import source from lvm2 2.02.79
[external/device-mapper.git] / lib / log / lvm-logging.h
1 /*
2  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
3  * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
4  *
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
9  * of the GNU Lesser General Public License v.2.1.
10  *
11  * You should have received a copy of the GNU Lesser General Public License
12  * along with this program; if not, write to the Free Software Foundation,
13  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14  */
15
16 #ifndef _LVM_LOGGING_H
17 #define _LVM_LOGGING_H
18
19 void print_log(int level, const char *file, int line, int dm_errno,
20                const char *format, ...)
21     __attribute__ ((format(printf, 5, 6)));
22
23 #define LOG_LINE(l, x...) \
24     print_log(l, __FILE__, __LINE__ , 0, ## x)
25
26 #define LOG_LINE_WITH_ERRNO(l, e, x...) \
27     print_log(l, __FILE__, __LINE__ , e, ## x)
28
29 #include "log.h"
30
31 typedef void (*lvm2_log_fn_t) (int level, const char *file, int line,
32                                int dm_errno, const char *message);
33
34 void init_log_fn(lvm2_log_fn_t log_fn);
35
36 void init_indent(int indent);
37 void init_msg_prefix(const char *prefix);
38
39 void init_log_file(const char *log_file, int append);
40 void init_log_direct(const char *log_file, int append);
41 void init_log_while_suspended(int log_while_suspended);
42 void init_abort_on_internal_errors(int fatal);
43
44 void fin_log(void);
45 void release_log_memory(void);
46 void reset_log_duplicated(void);
47
48 void init_syslog(int facility);
49 void fin_syslog(void);
50
51 int error_message_produced(void);
52 void reset_lvm_errno(int store_errmsg);
53 int stored_errno(void);
54 const char *stored_errmsg(void);
55
56 /* Suppress messages to stdout/stderr (1) or everywhere (2) */
57 /* Returns previous setting */
58 int log_suppress(int suppress);
59
60 /* Suppress messages to syslog */
61 void syslog_suppress(int suppress);
62
63 #endif