ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/slog.h
Revision: 1.2
Committed: Wed Apr 2 03:25:17 2003 UTC (21 years, 1 month ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.1: +2 -1 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 /*
2 slog.h -- logging
3
4 Copyright (C) 2003 Marc Lehmann <pcg@goof.com>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #ifndef SLOG_H__
22 #define SLOG_H__
23
24 enum loglevel {
25 L_NONE,
26 L_NOISE,
27 L_TRACE,
28 L_DEBUG,
29 L_INFO,
30 L_NOTICE,
31 L_WARN,
32 L_ERR,
33 L_CRIT
34 };
35
36 enum {
37 LOGTO_SYSLOG = 1,
38 LOGTO_STDERR = 2
39 };
40
41 extern loglevel log_level;
42 extern const char *log_identity;
43
44 extern loglevel string_to_loglevel (const char *s);
45 #define UNKNOWN_LOGLEVEL _("unknown loglevel, try 'noise', 'debug', 'info', 'notice', 'warn', 'error' or 'critical'")
46
47 inline void set_loglevel (const loglevel l)
48 {
49 log_level = l;
50 }
51
52 inline loglevel get_loglevel ()
53 {
54 return log_level;
55 }
56
57 inline void set_identity (const char *identname)
58 {
59 log_identity = identname;
60 }
61
62 inline const char *get_identity ()
63 {
64 return log_identity;
65 }
66
67 extern void log_to (int mask);
68
69 extern void slog_ (const loglevel l, const char *m, ...);
70
71 #ifdef __GNUC__
72 # define slog(l, ...) do { if ((l) >= log_level) slog_ (l, __VA_ARGS__); } while (0)
73 #else
74 # define slog slog_
75 #endif
76
77 extern void fatal (const char *m);
78
79 #endif
80