1 /*	$NetBSD: lvm-logging.h,v 1.1.1.2 2009/12/02 00:25:43 haad Exp $	*/
2 
3 /*
4  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5  * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
6  *
7  * This file is part of LVM2.
8  *
9  * This copyrighted material is made available to anyone wishing to use,
10  * modify, copy, or redistribute it subject to the terms and conditions
11  * of the GNU Lesser General Public License v.2.1.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software Foundation,
15  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17 
18 #ifndef _LVM_LOGGING_H
19 #define _LVM_LOGGING_H
20 
21 void print_log(int level, const char *file, int line, int dm_errno,
22 	       const char *format, ...)
23     __attribute__ ((format(printf, 5, 6)));
24 
25 #define LOG_LINE(l, x...) \
26     print_log(l, __FILE__, __LINE__ , 0, ## x)
27 
28 #define LOG_LINE_WITH_ERRNO(l, e, x...) \
29     print_log(l, __FILE__, __LINE__ , e, ## x)
30 
31 #include "log.h"
32 
33 typedef void (*lvm2_log_fn_t) (int level, const char *file, int line,
34 			       int dm_errno, const char *message);
35 
36 void init_log_fn(lvm2_log_fn_t log_fn);
37 
38 void init_indent(int indent);
39 void init_msg_prefix(const char *prefix);
40 
41 void init_log_file(const char *log_file, int append);
42 void init_log_direct(const char *log_file, int append);
43 void init_log_while_suspended(int log_while_suspended);
44 
45 void fin_log(void);
46 void release_log_memory(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
64