]>
git.proxmox.com Git - mirror_frr.git/blob - lib/log.h
1 /* Zebra logging funcions.
2 * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 #define ZLOG_NOLOG 0x00
28 #define ZLOG_FILE 0x01
29 #define ZLOG_SYSLOG 0x02
30 #define ZLOG_STDOUT 0x04
31 #define ZLOG_STDERR 0x08
33 #define ZLOG_NOLOG_INDEX 0
34 #define ZLOG_FILE_INDEX 1
35 #define ZLOG_SYSLOG_INDEX 2
36 #define ZLOG_STDOUT_INDEX 3
37 #define ZLOG_STDERR_INDEX 4
38 #define ZLOG_MAX_INDEX 5
56 zlog_proto_t protocol
;
63 int maskpri
; /* as per syslog setlogmask */
64 int priority
; /* as per syslog priority */
65 int facility
; /* as per syslog facility */
69 /* Message structure. */
76 /* Default logging strucutre. */
77 extern struct zlog
*zlog_default
;
79 /* Open zlog function */
80 struct zlog
*openzlog (const char *, int, zlog_proto_t
, int, int);
82 /* Close zlog function. */
83 void closezlog (struct zlog
*zl
);
85 /* GCC have printf type attribute check. */
87 #define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
89 #define PRINTF_ATTRIBUTE(a,b)
92 /* Generic function for zlog. */
93 void zlog (struct zlog
*zl
, int priority
, const char *format
, ...) PRINTF_ATTRIBUTE(3, 4);
95 /* Handy zlog functions. */
96 void zlog_err (const char *format
, ...) PRINTF_ATTRIBUTE(1, 2);
97 void zlog_warn (const char *format
, ...) PRINTF_ATTRIBUTE(1, 2);
98 void zlog_info (const char *format
, ...) PRINTF_ATTRIBUTE(1, 2);
99 void zlog_notice (const char *format
, ...) PRINTF_ATTRIBUTE(1, 2);
100 void zlog_debug (const char *format
, ...) PRINTF_ATTRIBUTE(1, 2);
102 /* For bgpd's peer oriented log. */
103 void plog_err (struct zlog
*, const char *format
, ...);
104 void plog_warn (struct zlog
*, const char *format
, ...);
105 void plog_info (struct zlog
*, const char *format
, ...);
106 void plog_notice (struct zlog
*, const char *format
, ...);
107 void plog_debug (struct zlog
*, const char *format
, ...);
109 /* Set zlog flags. */
110 void zlog_set_flag (struct zlog
*zl
, int flags
);
111 void zlog_reset_flag (struct zlog
*zl
, int flags
);
113 /* Set zlog filename. */
114 int zlog_set_file (struct zlog
*zl
, int flags
, char *filename
);
115 int zlog_reset_file (struct zlog
*zl
);
120 /* For hackey massage lookup and check */
121 #define LOOKUP(x, y) mes_lookup(x, x ## _max, y)
123 char *lookup (struct message
*, int);
124 char *mes_lookup (struct message
*meslist
, int max
, int index
);
126 extern const char *zlog_priority
[];
128 #endif /* _ZEBRA_LOG_H */