2 * Copyright (c) 1995-2003, Index Data.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation, in whole or in part, for any purpose, is hereby granted,
8 * 1. This copyright and permission notice appear in all copies of the
9 * software and its documentation. Notices of copyright or attribution
10 * which appear at the beginning of any file must remain unchanged.
12 * 2. The name of Index Data or the individual authors may not be used to
13 * endorse or promote products derived from this software without specific
14 * prior written permission.
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19 * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20 * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22 * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26 * $Id: log.h,v 1.15 2004-11-02 12:55:04 heikki Exp $
31 * \brief Header for logging utility
38 #include <yaz/yconfig.h>
39 #include <yaz/xmalloc.h>
43 #define LOG_FATAL 0x00000001
44 #define LOG_DEBUG 0x00000002
45 #define LOG_WARN 0x00000004
46 #define LOG_LOG 0x00000008
47 #define LOG_ERRNO 0x00000010 /* append strerror to message */
48 #define LOG_FILE 0x00000020
49 #define LOG_APP 0x00000040 /* Application level events (new-connection) */
50 #define LOG_MALLOC 0x00000080 /* debugging mallocs */
51 #define LOG_NOTIME 0x00000100 /* do not output date and time */
52 #define LOG_APP2 0x00000200 /* Application-level events, such as api calls */
53 #define LOG_APP3 0x00000400 /* For more application-level events */
54 #define LOG_FLUSH 0x00000800 /* Flush log after every write (DEBUG does too) */
56 #define LOG_ALL (0xffff&~LOG_MALLOC&~LOG_NOTIME)
58 #define LOG_DEFAULT_LEVEL (LOG_FATAL | LOG_ERRNO | LOG_LOG | LOG_WARN)
62 YAZ_EXPORT void yaz_log_init(int level, const char *prefix, const char *name);
63 YAZ_EXPORT void yaz_log_init_file (const char *fname);
64 YAZ_EXPORT void yaz_log_init_level (int level);
65 YAZ_EXPORT void yaz_log_init_prefix (const char *prefix);
66 YAZ_EXPORT void yaz_log_init_prefix2 (const char *prefix);
68 * yaz_log_time_format sets the format of the timestamp. See man 3 strftime
69 * Calling with "old" sets to the old format "11:55:06-02/11"
70 * Calling with NULL or "" sets to the new format "20041102-115719"
71 * If not called at all, the old format is used, for backward compatibility
74 YAZ_EXPORT void yaz_log_time_format(const char *fmt);
76 YAZ_EXPORT void yaz_log(int level, const char *fmt, ...)
78 __attribute__ ((format (printf, 2, 3)))
81 YAZ_EXPORT int yaz_log_mask_str (const char *str);
82 YAZ_EXPORT int yaz_log_mask_str_x (const char *str, int level);
83 YAZ_EXPORT FILE *yaz_log_file(void);
85 YAZ_EXPORT void log_event_start (void (*func)(int level, const char *msg, void *info),
87 YAZ_EXPORT void log_event_end (void (*func)(int level, const char *msg, void *info),
90 YAZ_EXPORT void yaz_log_reopen(void);