lessfs  1.7.0
About: Lessfs is a inline data deduplicating file system for Linux (implemented in user space with FUSE; especially useful for backup purposes).
  Fossies Dox: lessfs-1.7.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

lib_log.h
Go to the documentation of this file.
1 /* lib_log.h. Generated from lib_log.h.in by configure. */
2 /*
3  * Lessfs: A data deduplicating filesystem.
4  * Copyright (C) 2008 Mark Ruijter <mruijter@lessfs.com>
5  *
6  * This program is free software.
7  * You can redistribute lessfs and/or modify it under the terms of either
8  * (1) the GNU General Public License; either version 3 of the License,
9  * or (at your option) any later version as published by
10  * the Free Software Foundation; or (2) obtain a commercial license
11  * by contacting the Author.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
16  * the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  * Logging debug=0 -> Alleen fatals
23  * debug=1 -> fatals + warnings
24  * debug=2 -> fatals + warnings + info
25  * debug=3 -> fatals + warnings + info + debug
26 */
27 
28 #ifdef SYSLOG
29 #include<syslog.h>
30 #endif
31 #include <sys/types.h>
32 #include <unistd.h>
33 #include <sys/times.h>
34 
35 extern char *logname;
36 extern char *function;
37 extern int debug;
38 
39 #define BUFSIZE 1024
40 
41 #if !defined FACILITY
42 #define FACILITY LOG_LOCAL0
43 #endif
44 #if !defined PRIORITY
45 #define PRIORITY LOG_NOTICE
46 #endif
47 
48 #ifdef FILELOG
49 #define LFSFILELOG "/var/log/lessfs.log"
50 #define LLINF(t,f...) {wfile_log(LFSFILELOG,__FILE__,__LINE__, f);}
51 #define LLINW(t,f...) {wfile_log(LFSFILELOG,__FILE__,__LINE__, f);}
52 #define LLINI(t,f...) {wfile_log(LFSFILELOG,__FILE__,__LINE__, f);}
53 #define LLIND(t,f...) {wfile_log(LFSFILELOG,__FILE__,__LINE__, f);}
54 #else
55 #ifdef SYSLOG
56 #define LLINF(t,f...) {openlog(logname,LOG_PID,FACILITY);syslog(LOG_CRIT,f);closelog();}
57 #define LLINW(t,f...) {if ( debug > 0 ){ openlog(logname,LOG_PID,FACILITY);syslog(LOG_WARNING,f);closelog();};}
58 #define LLINI(t,f...) {if ( debug > 1 ){ openlog(logname,LOG_PID,FACILITY);syslog(LOG_INFO,f);closelog();};}
59 #define LLIND(t,f...) {if ( debug > 2 ){ openlog(logname,LOG_PID,FACILITY);syslog(LOG_DEBUG,f);closelog();};}
60 #else
61 #define LLINF(t,f...) {if ( debug > 0 ){ fprintf(stderr,f); fprintf(stderr,"\n");};}
62 #define LLINW(t,f...) {if ( debug > 1 ){ fprintf(stderr,f); fprintf(stderr,"\n");};}
63 #define LLINI(t,f...) {if ( debug > 2 ){ fprintf(stderr,f); fprintf(stderr,"\n");};}
64 #define LLIND(t,f...) {if ( debug > 3 ){ fprintf(stderr,"%s - %s (%i): %s: \n",logname,__PRETTY_FUNCTION__,getpid(),t); fprintf(stderr,f);};}
65 #endif
66 #endif
67 
68 #define LFATAL(f...) {LLINF("fatal",f);}
69 #define LINFO(f...) {LLINI("info",f);}
70 #define LWARNING(f...){LLINW("warning",f);}
71 #ifdef DEBUG
72 #define LDEBUG(f...) {LLIND("debug",f);}
73 #define FUNC {logname=(char *)__FILE__; function=(char *)__PRETTY_FUNCTION__;if ( debug > 4 ) tstamp();};
74 #define EFUNC {logname=(char *)__FILE__; function=(char *)__PRETTY_FUNCTION__;if ( debug > 4 ) estamp();};
75 #else
76 #define FUNC {};
77 #define EFUNC {};
78 #define LDEBUG(f...) {};
79 #endif
logname
char * logname
Definition: commons.h:5
debug
int debug
Definition: commons.h:7