2 * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #ifndef _ARLAUTIL_LOG_H
37 #define _ARLAUTIL_LOG_H 1
40 #include <parse_units.h>
42 #if !defined(__GNUC__) && !defined(__attribute__)
43 #define __attribute__(x)
50 typedef struct log_method Log_method
;
51 typedef struct log_unit Log_unit
;
54 * Functions for handling logging
57 Log_method
*log_open (const char *progname
, char *fname
);
58 /* Starting logging to `fname'. Label all messages as coming from
61 void log_close (Log_method
*logm
);
63 Log_unit
*log_unit_init (Log_method
*method
, const char *name
,
64 struct units
*lognames
,
65 unsigned long default_mask
);
67 void log_unit_free (Log_method
*method
, Log_unit
*logu
);
69 log_flags
log_setflags(Log_method
*logm
, log_flags flags
);
70 log_flags
log_getflags(Log_method
*logm
);
72 void log_log (Log_unit
*logu
, unsigned level
, const char *fmt
, ...)
73 __attribute__((format (printf
, 3, 4)))
76 void log_vlog(Log_unit
*logu
, unsigned level
, const char *fmt
, va_list args
)
77 __attribute__((format (printf
, 3, 0)))
80 unsigned log_get_mask (Log_unit
*logu
);
82 void log_set_mask (Log_unit
*logu
, unsigned mask
);
84 void log_set_mask_str (Log_method
*method
, Log_unit
*default_unit
,
87 size_t log_mask2str (Log_method
*method
, Log_unit
*unit
, char *buf
, size_t sz
);
89 #endif /* _ARLAUTIL_LOG_H */