ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/slog.h
Revision: 1.5
Committed: Thu Jan 29 18:55:10 2004 UTC (20 years, 4 months ago) by pcg
Content type: text/plain
Branch: MAIN
CVS Tags: VPE_1_6, rel-1_7, VPE-1_6_1
Changes since 1.4: +3 -0 lines
Log Message:
*** empty log message ***

File Contents

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