2 Copyright (c) 2003-2006 by Juliusz Chroboczek
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #define L_FORBIDDEN 0x4
26 #define L_UNCACHEABLE 0x8
27 #define L_SUPERSEDED 0x10
30 #define D_SERVER_CONN 0x100
31 #define D_SERVER_REQ 0x200
32 #define D_CLIENT_CONN 0x400
33 #define D_CLIENT_REQ 0x800
34 #define D_ATOM_REFCOUNT 0x1000
35 #define D_REFCOUNT 0x2000
37 #define D_OBJECT 0x8000
38 #define D_OBJECT_DATA 0x10000
39 #define D_SERVER_OFFSET 0x20000
40 #define D_CLIENT_DATA 0x40000
42 #define D_CHILD 0x100000
44 #define D_TRANSCODE 0x400000
46 #define LOGGING_DEFAULT (L_ERROR | L_WARN | L_UNCACHEABLE)
47 #define LOGGING_MAX 0xFF
49 extern AtomPtr logFile
;
52 void preinitLog(void);
56 void really_do_log(int type
, const char *f
, ...)
57 ATTRIBUTE ((format (printf
, 2, 3)));
58 void really_do_log_v(int type
, const char *f
, va_list args
);
59 void really_do_log_n(int type
, const char *s
, int n
);
60 void really_do_log_error(int type
, int e
, const char *f
, ...)
61 ATTRIBUTE((format (printf
, 3, 4)));
62 void really_do_log_error_v(int type
, int e
, const char *f
, va_list args
);
65 #define DO_BACKTRACE() \
69 n = backtrace(buffer, 5); \
71 backtrace_symbols_fd(buffer, n, 2); \
74 #define DO_BACKTRACE() /* */
77 /* These are macros because it's important that they should be
80 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
82 #define do_log(_type, ...) \
84 if((_type) & (LOGGING_MAX)) really_do_log((_type), __VA_ARGS__); \
86 #define do_log_error(_type, _e, ...) \
88 if((_type) & (LOGGING_MAX)) \
89 really_do_log_error((_type), (_e), __VA_ARGS__); \
92 #elif defined(__GNUC__)
94 #define do_log(_type, _args...) \
96 if((_type) & (LOGGING_MAX)) really_do_log((_type), _args); \
98 #define do_log_error(_type, _e, _args...) \
100 if((_type) & (LOGGING_MAX)) \
101 really_do_log_error((_type), (_e), _args); \
106 /* No variadic macros -- let's hope inline works. */
109 do_log(int type
, const char *f
, ...)
114 if((type
& (LOGGING_MAX
)) != 0)
115 really_do_log_v(type
, f
, args
);
120 do_log_error(int type
, int e
, const char *f
, ...)
125 if((type
& (LOGGING_MAX
)) != 0)
126 really_do_log_error_v(type
, e
, f
, args
);
132 #define do_log_n(_type, _s, _n) \
134 if((_type) & (LOGGING_MAX)) really_do_log_n((_type), (_s), (_n)); \