YAZ 5.35.1
log.h
Go to the documentation of this file.
1/* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data.
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Index Data nor the names of its contributors
13 * may be used to endorse or promote products derived from this
14 * software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
33#ifndef YAZ_LOG_H
34#define YAZ_LOG_H
35
36#include <stdio.h>
37#include <yaz/yconfig.h>
38
40
42#define YLOG_FATAL 0x00000001
44#define YLOG_DEBUG 0x00000002
46#define YLOG_WARN 0x00000004
48#define YLOG_LOG 0x00000008
50#define YLOG_ERRNO 0x00000010
52#define YLOG_TID 0x00000020
54#define YLOG_APP 0x00000040
56#define YLOG_MALLOC 0x00000080
58#define YLOG_NOTIME 0x00000100
60#define YLOG_APP2 0x00000200
62#define YLOG_APP3 0x00000400
64#define YLOG_FLUSH 0x00000800
66#define YLOG_LOGLVL 0x00001000 /* log when modules query log levels */
67 /* this has to be a hard-coded bit, not to loop*/
68
69#define YLOG_ALL (0xffff&~YLOG_MALLOC&~YLOG_NOTIME)
70
72#define YLOG_DEFAULT_LEVEL \
73 (YLOG_FATAL | YLOG_ERRNO | YLOG_LOG | YLOG_WARN | YLOG_FLUSH)
74/* not having flush here confuses Solaris users, who won't see any logs until
75 * (and if) the program exits normally */
76
78#define YLOG_LAST_BIT YLOG_LOGLVL
79
87YAZ_EXPORT void yaz_log_init(int level, const char *prefix, const char *fname);
88
97YAZ_EXPORT void yaz_log_init_file(const char *fname);
98
102YAZ_EXPORT void yaz_log_init_level(int level);
103
107YAZ_EXPORT void yaz_log_init_prefix(const char *prefix);
108
112YAZ_EXPORT void yaz_log_init_prefix2(const char *prefix);
113
122YAZ_EXPORT void yaz_log_time_format(const char *fmt);
123
130YAZ_EXPORT void yaz_log_init_max_size(int mx);
131
140YAZ_EXPORT void yaz_log(int level, const char *fmt, ...)
141#ifdef __GNUC__
142 __attribute__ ((format (printf, 2, 3)))
143#endif
144 ;
145
156YAZ_EXPORT int yaz_log_mask_str(const char *str);
157
166YAZ_EXPORT int yaz_log_mask_str_x(const char *str, int level);
167
178YAZ_EXPORT int yaz_log_module_level(const char *name);
179
184YAZ_EXPORT FILE *yaz_log_file(void);
185
193YAZ_EXPORT void yaz_log_set_handler(void (*func)(int, const char *,
194 void *), void *info);
195
198YAZ_EXPORT void yaz_log_reopen(void);
199
201YAZ_EXPORT void yaz_log_trunc(void);
202
207YAZ_EXPORT void log_event_start(void (*func)(int level, const char *msg,
208 void *info), void *info);
209
214YAZ_EXPORT void log_event_end(void (*func)(int level, const char *msg,
215 void *info), void *info);
216
221YAZ_EXPORT void yaz_log_xml_errors(const char *prefix, int log_level);
222
225YAZ_EXPORT void yaz_log_lock(void);
226
229YAZ_EXPORT void yaz_log_unlock(void);
231
232#endif
233/*
234 * Local variables:
235 * c-basic-offset: 4
236 * c-file-style: "Stroustrup"
237 * indent-tabs-mode: nil
238 * End:
239 * vim: shiftwidth=4 tabstop=8 expandtab
240 */
241
static int log_level
Definition eventl.c:39
char * name
Definition initopt.c:18
void yaz_log_set_handler(void(*func)(int, const char *, void *), void *info)
sets custom log handler
Definition log.c:298
void yaz_log_init_prefix(const char *prefix)
sets log message prefix
Definition log.c:263
int yaz_log_mask_str(const char *str)
converts log level string to log level (integer)
Definition log.c:606
void yaz_log_init_max_size(int mx)
sets limit in bytes for size for log file
Definition log.c:290
void yaz_log_reopen(void)
reopen current log file (unless disabled or stderr)
Definition log.c:391
void yaz_log_trunc(void)
Truncate the log file.
Definition log.c:401
void yaz_log_init_prefix2(const char *prefix)
sets second log message prefix
Definition log.c:272
void yaz_log_init_level(int level)
sets log level
Definition log.c:228
void log_event_start(void(*func)(int level, const char *msg, void *info), void *info)
installs hook to be called before each log msg
void yaz_log_init(int level, const char *prefix, const char *fname)
sets level, prefix and filename for logging
Definition log.c:281
void yaz_log_xml_errors(const char *prefix, int log_level)
Makes Libxml2 and Libxslt log errors through yaz_log.
Definition xmlerror.c:47
void yaz_log_lock(void)
Lock for YAZ log writes.
Definition log.c:114
void yaz_log_time_format(const char *fmt)
sets time format for log mesages
Definition log.c:529
void log_event_end(void(*func)(int level, const char *msg, void *info), void *info)
installs hook to be called after each log msg
void yaz_log(int level, const char *fmt,...)
Writes log message.
Definition log.c:487
void yaz_log_init_file(const char *fname)
sets log file
Definition log.c:168
void yaz_log_unlock(void)
Unlock for YAZ log writes.
Definition log.c:119
int yaz_log_mask_str_x(const char *str, int level)
converts log level string to log level with "start" level
Definition log.c:614
int yaz_log_module_level(const char *name)
returns level for module
Definition log.c:586
FILE * yaz_log_file(void)
returns FILE handle for log or NULL if no file is in use
Definition log.c:138
Header with fundamental macros.
#define YAZ_BEGIN_CDECL
Definition yconfig.h:56
#define YAZ_END_CDECL
Definition yconfig.h:57