Super User's BSD Cross Reference: /OpenBSD/usr.sbin/lldpd/log.h

1
2 /*
3 * Copyright (c) 2008 David Gwynne <loki@animata.net>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef _LOG_H_
19#define _LOG_H_
20
21 struct __logger {
22 __dead void (*err)(int, const char *, ...)
23 __attribute__((__format__ (printf, 2, 3)));
24 __dead void (*errx)(int, const char *, ...)
25 __attribute__((__format__ (printf, 2, 3)));
26 void (*warn)(const char *, ...)
27 __attribute__((__format__ (printf, 1, 2)));
28 void (*warnx)(const char *, ...)
29 __attribute__((__format__ (printf, 1, 2)));
30 void (*info)(const char *, ...)
31 __attribute__((__format__ (printf, 1, 2)));
32 void (*debug)(const char *, ...)
33 __attribute__((__format__ (printf, 1, 2)));
34};
35
36 extern const struct __logger *__logger;
37
38#define lerr(_e, _f...) __logger->err((_e), _f)
39#define lerrx(_e, _f...) __logger->errx((_e), _f)
40#define lwarn(_f...) __logger->warn(_f)
41#define lwarnx(_f...) __logger->warnx(_f)
42#define linfo(_f...) __logger->info(_f)
43#define ldebug(_f...) __logger->debug(_f)
44
45 void logger_syslog(const char *, int);
46
47#endif /* _LOG_H_ */
48 

AltStyle によって変換されたページ (->オリジナル) /