ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/slog.h
Revision: 1.8
Committed: Thu Aug 7 17:54:27 2008 UTC (15 years, 9 months ago) by pcg
Content type: text/plain
Branch: MAIN
CVS Tags: rel-3_0, rel-2_2, rel-2_21, rel-2_22, rel-2_25, HEAD
Changes since 1.7: +24 -14 lines
Log Message:
update to gplv3, finally

File Contents

# User Rev Content
1 pcg 1.1 /*
2     slog.h -- logging
3 pcg 1.8 Copyright (C) 2003-2008 Marc Lehmann <gvpe@schmorp.de>
4 pcg 1.1
5 pcg 1.6 This file is part of GVPE.
6    
7 pcg 1.8 GVPE is free software; you can redistribute it and/or modify it
8     under the terms of the GNU General Public License as published by the
9     Free Software Foundation; either version 3 of the License, or (at your
10     option) any later version.
11    
12     This program is distributed in the hope that it will be useful, but
13     WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15     Public License for more details.
16    
17     You should have received a copy of the GNU General Public License along
18     with this program; if not, see <http://www.gnu.org/licenses/>.
19    
20     Additional permission under GNU GPL version 3 section 7
21    
22     If you modify this Program, or any covered work, by linking or
23     combining it with the OpenSSL project's OpenSSL library (or a modified
24     version of that library), containing parts covered by the terms of the
25     OpenSSL or SSLeay licenses, the licensors of this Program grant you
26     additional permission to convey the resulting work. Corresponding
27     Source for a non-source form of such a combination shall include the
28     source code for the parts of OpenSSL used as well as that of the
29     covered work.
30 pcg 1.1 */
31    
32     #ifndef SLOG_H__
33     #define SLOG_H__
34    
35     enum loglevel {
36     L_NONE,
37     L_NOISE,
38     L_TRACE,
39     L_DEBUG,
40     L_INFO,
41     L_NOTICE,
42     L_WARN,
43     L_ERR,
44     L_CRIT
45     };
46    
47     enum {
48     LOGTO_SYSLOG = 1,
49     LOGTO_STDERR = 2
50     };
51    
52     extern loglevel log_level;
53     extern const char *log_identity;
54    
55     extern loglevel string_to_loglevel (const char *s);
56     #define UNKNOWN_LOGLEVEL _("unknown loglevel, try 'noise', 'debug', 'info', 'notice', 'warn', 'error' or 'critical'")
57    
58     inline void set_loglevel (const loglevel l)
59     {
60     log_level = l;
61     }
62    
63     inline loglevel get_loglevel ()
64     {
65     return log_level;
66     }
67    
68     inline void set_identity (const char *identname)
69     {
70     log_identity = identname;
71     }
72    
73     inline const char *get_identity ()
74     {
75     return log_identity;
76     }
77    
78     extern void log_to (int mask);
79    
80     extern void slog_ (const loglevel l, const char *m, ...);
81    
82 pcg 1.3 #if __GNUC__ > 2
83 pcg 1.1 # define slog(l, ...) do { if ((l) >= log_level) slog_ (l, __VA_ARGS__); } while (0)
84     #else
85     # define slog slog_
86     #endif
87    
88     extern void fatal (const char *m);
89 pcg 1.5 extern void require_failed (const char *file, int line, const char *info);
90    
91     #define require(expr) if (!(expr)) require_failed (__FILE__, __LINE__, #expr)
92 pcg 1.1
93     #endif
94