]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* Zebra logging funcions. |
2 | * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro | |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
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 | |
9 | * later version. | |
10 | * | |
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. | |
15 | * | |
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 | |
19 | * 02111-1307, USA. | |
20 | */ | |
21 | ||
22 | #ifndef _ZEBRA_LOG_H | |
23 | #define _ZEBRA_LOG_H | |
24 | ||
25 | #include <syslog.h> | |
26 | ||
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 | |
32 | ||
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 | |
39 | ||
40 | typedef enum | |
41 | { | |
42 | ZLOG_NONE, | |
43 | ZLOG_DEFAULT, | |
44 | ZLOG_ZEBRA, | |
45 | ZLOG_RIP, | |
46 | ZLOG_BGP, | |
47 | ZLOG_OSPF, | |
48 | ZLOG_RIPNG, | |
49 | ZLOG_OSPF6, | |
9e867fe6 | 50 | ZLOG_ISIS, |
718e3744 | 51 | ZLOG_MASC |
52 | } zlog_proto_t; | |
53 | ||
54 | struct zlog | |
55 | { | |
56 | const char *ident; | |
57 | zlog_proto_t protocol; | |
58 | int flags; | |
59 | FILE *fp; | |
60 | char *filename; | |
61 | int syslog; | |
62 | int stat; | |
63 | int connected; | |
64 | int maskpri; /* as per syslog setlogmask */ | |
65 | int priority; /* as per syslog priority */ | |
66 | int facility; /* as per syslog facility */ | |
67 | int record_priority; | |
68 | }; | |
69 | ||
70 | /* Message structure. */ | |
71 | struct message | |
72 | { | |
73 | int key; | |
74 | char *str; | |
75 | }; | |
76 | ||
77 | /* Default logging strucutre. */ | |
78 | extern struct zlog *zlog_default; | |
79 | ||
80 | /* Open zlog function */ | |
81 | struct zlog *openzlog (const char *, int, zlog_proto_t, int, int); | |
82 | ||
83 | /* Close zlog function. */ | |
84 | void closezlog (struct zlog *zl); | |
85 | ||
86 | /* GCC have printf type attribute check. */ | |
87 | #ifdef __GNUC__ | |
88 | #define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b))) | |
89 | #else | |
90 | #define PRINTF_ATTRIBUTE(a,b) | |
91 | #endif /* __GNUC__ */ | |
92 | ||
93 | /* Generic function for zlog. */ | |
94 | void zlog (struct zlog *zl, int priority, const char *format, ...) PRINTF_ATTRIBUTE(3, 4); | |
95 | ||
96 | /* Handy zlog functions. */ | |
97 | void zlog_err (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); | |
98 | void zlog_warn (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); | |
99 | void zlog_info (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); | |
100 | void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); | |
101 | void zlog_debug (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); | |
102 | ||
103 | /* For bgpd's peer oriented log. */ | |
104 | void plog_err (struct zlog *, const char *format, ...); | |
105 | void plog_warn (struct zlog *, const char *format, ...); | |
106 | void plog_info (struct zlog *, const char *format, ...); | |
107 | void plog_notice (struct zlog *, const char *format, ...); | |
108 | void plog_debug (struct zlog *, const char *format, ...); | |
109 | ||
110 | /* Set zlog flags. */ | |
111 | void zlog_set_flag (struct zlog *zl, int flags); | |
112 | void zlog_reset_flag (struct zlog *zl, int flags); | |
113 | ||
114 | /* Set zlog filename. */ | |
115 | int zlog_set_file (struct zlog *zl, int flags, char *filename); | |
116 | int zlog_reset_file (struct zlog *zl); | |
117 | ||
118 | /* Rotate log. */ | |
119 | int zlog_rotate (); | |
120 | ||
121 | /* For hackey massage lookup and check */ | |
122 | #define LOOKUP(x, y) mes_lookup(x, x ## _max, y) | |
123 | ||
124 | char *lookup (struct message *, int); | |
125 | char *mes_lookup (struct message *meslist, int max, int index); | |
126 | ||
127 | extern const char *zlog_priority[]; | |
128 | ||
129 | #endif /* _ZEBRA_LOG_H */ |