author | Tero Marttila <terom@fixme.fi> |
Thu, 21 May 2009 17:08:47 +0300 | |
changeset 214 | 0d5d46ab49d5 |
parent 157 | 1e5674d0eec4 |
permissions | -rw-r--r-- |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
/** |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
* @file |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
* |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
* A module to filter out certain lines from normal syslog() files, and forward them to an IRC channel. |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
*/ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
#include <sys/queue.h> |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
#include "../irc_chan.h" |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
#include "../line_proto.h" |
157 | 9 |
#include "../nexus.h" |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
#include <event2/event.h> |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
#include <pcre.h> |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
/** |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
* A source of log lines. |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
* |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
* XXX: currently this is just hardcoded to be a FIFO |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
*/ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
struct logwatch_source { |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
20 |
/** The logwatch context we are registered to */ |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
21 |
struct logwatch *ctx; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
|
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
23 |
/** Our name */ |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
24 |
char *name; |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
25 |
|
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
/** The input FIFO */ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
struct line_proto *lp; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
29 |
/** Our entry in logwatch::sources */ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
TAILQ_ENTRY(logwatch_source) logwatch_sources; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
}; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
/** |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
* Maximum length of input lines |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
*/ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
#define LOGWATCH_SOURCE_LINE_MAX 1024 |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
/** |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
39 |
* Logwatch's per-channel state |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
40 |
*/ |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
41 |
struct logwatch_chan { |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
42 |
/** The logwatch context we are registered to */ |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
43 |
struct logwatch *ctx; |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
44 |
|
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
45 |
/** The actual irc_chan */ |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
46 |
struct irc_chan *irc_chan; |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
47 |
|
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
48 |
/** Number of references */ |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
49 |
size_t refcount; |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
50 |
|
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
51 |
/** Our entry in logwatch::channels */ |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
52 |
TAILQ_ENTRY(logwatch_chan) logwatch_channels; |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
53 |
}; |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
54 |
|
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
55 |
/** |
133
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
56 |
* Maximum length of a logwatch_chan message, not including NUL byte |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
57 |
* |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
58 |
* XXX: this is a bad way to handle truncation |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
59 |
*/ |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
60 |
#define LOGWATCH_CHAN_MSG_MAX 470 |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
61 |
|
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
62 |
/** |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
63 |
* A filter specifies what lines to match, and how to then format the output. |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
64 |
*/ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
65 |
struct logwatch_filter { |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
66 |
/** The logwatch context we are registered to */ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
67 |
struct logwatch *ctx; |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
68 |
|
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
69 |
/** The name of the filter */ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
70 |
char *name; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
71 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
72 |
/** The source to restrict this to, if any */ |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
73 |
const struct logwatch_source *source; |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
74 |
|
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
75 |
/** |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
76 |
* The compiled regular expression to match, or NULL to match all lines. |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
77 |
*/ |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
78 |
pcre *regexp; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
79 |
|
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
80 |
/** |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
81 |
* The output format string, or NULL to send the line itself as-is |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
82 |
*/ |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
83 |
char *format; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
84 |
|
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
85 |
/** |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
86 |
* The channel to send output to |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
87 |
*/ |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
88 |
struct logwatch_chan *chan; |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
89 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
90 |
/** Our entry in logwatch::filters */ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
91 |
TAILQ_ENTRY(logwatch_filter) logwatch_filters; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
92 |
}; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
93 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
94 |
/** |
127
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
95 |
* Maximum number of capture groups in the filter's regexp |
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
96 |
*/ |
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
97 |
#define LOGWATCH_FILTER_GROUPS_MAX 16 |
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
98 |
|
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
99 |
/** |
133
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
100 |
* Maximum length of logwatch_filter output |
127
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
101 |
*/ |
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
102 |
#define LOGWATCH_FILTER_OUT_MAX 450 |
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
103 |
|
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
104 |
/** |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
105 |
* The logwatch module state |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
106 |
*/ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
107 |
struct logwatch { |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
108 |
/** The nexus we are loaded on */ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
109 |
struct nexus *nexus; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
110 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
111 |
/** List of sources */ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
112 |
TAILQ_HEAD(logwatch_source_list, logwatch_source) sources; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
113 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
114 |
/** List of filters */ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
115 |
TAILQ_HEAD(logwatch_filter_list, logwatch_filter) filters; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
116 |
|
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
117 |
/** List of chanenls */ |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
118 |
TAILQ_HEAD(logwatch_chan_list, logwatch_chan) channels; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
119 |
}; |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
120 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
121 |
/** |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
122 |
* Add a new FIFO logwatch_source |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
123 |
* |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
124 |
* @param ctx the logwatch state |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
125 |
* @param path the path to the fifo, also used as the name |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
126 |
* @param err returned error info |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
127 |
* @return the new logwatch_source, or NULL on error |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
128 |
*/ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
129 |
struct logwatch_source* logwatch_open_fifo (struct logwatch *ctx, const char *path, struct error_info *err); |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
130 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
131 |
/** |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
132 |
* Destroy a source, removing it from the list of sources. |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
133 |
* |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
134 |
* XXX: remove all affected filters as well |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
135 |
*/ |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
136 |
void logwatch_source_destroy (struct logwatch_source *source); |
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
137 |
|
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
138 |
/** |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
139 |
* Lookup a logwatch_source by name |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
140 |
*/ |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
141 |
const struct logwatch_source* logwatch_source_lookup (struct logwatch *ctx, const char *name); |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
142 |
|
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
143 |
/** |
133
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
144 |
* Returns true if the given chan is linked to the given source via at least one filter |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
145 |
*/ |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
146 |
bool logwatch_chan_has_source (struct logwatch_chan *chan, const struct logwatch_source *source); |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
147 |
|
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
148 |
/** |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
149 |
* Look for an existing logwatch_chan entry, returning it if it exists |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
150 |
*/ |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
151 |
struct logwatch_chan* logwatch_chan_lookup (struct logwatch *ctx, struct irc_chan *irc_chan); |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
152 |
|
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
153 |
/** |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
154 |
* Create a new irc_chan with an initial refcount of one. |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
155 |
* |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
156 |
* @returns NULL on ERR_CALLOC |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
157 |
*/ |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
158 |
struct logwatch_chan* logwatch_chan_create (struct logwatch *ctx, struct irc_chan *irc_chan); |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
159 |
|
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
160 |
/** |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
161 |
* Returns a logwatch_chan reference, destroying as needed. |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
162 |
*/ |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
163 |
void logwatch_chan_put (struct logwatch_chan *chan); |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
164 |
|
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
165 |
/** |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
166 |
* Send a notice of at most LOGWATCH_CHAN_MSG_MAX bytes to the channel using the given format string. |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
167 |
*/ |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
168 |
err_t logwatch_chan_msg (struct logwatch_chan *chan, const char *fmt, ...); |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
169 |
|
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
170 |
/** |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
171 |
* Find an existing logwatch_chan for the given channel, or create a new one. Returns a real reference that should be |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
172 |
* returned using logwatch_put_chan(). |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
173 |
* |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
174 |
* @returns NULL on ERR_CALLOC |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
175 |
*/ |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
176 |
struct logwatch_chan* logwatch_get_chan (struct logwatch *ctx, struct irc_chan *irc_chan); |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
177 |
|
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
178 |
/** |
135
9159bd51525f
have logwatch_conf_filter replace any old filter with the same name, and move irc_log.sql to modules/
Tero Marttila <terom@fixme.fi>
parents:
133
diff
changeset
|
179 |
* Lookup an existing filter by name. |
9159bd51525f
have logwatch_conf_filter replace any old filter with the same name, and move irc_log.sql to modules/
Tero Marttila <terom@fixme.fi>
parents:
133
diff
changeset
|
180 |
*/ |
9159bd51525f
have logwatch_conf_filter replace any old filter with the same name, and move irc_log.sql to modules/
Tero Marttila <terom@fixme.fi>
parents:
133
diff
changeset
|
181 |
struct logwatch_filter* logwatch_filter_lookup (struct logwatch *ctx, const char *name); |
9159bd51525f
have logwatch_conf_filter replace any old filter with the same name, and move irc_log.sql to modules/
Tero Marttila <terom@fixme.fi>
parents:
133
diff
changeset
|
182 |
|
9159bd51525f
have logwatch_conf_filter replace any old filter with the same name, and move irc_log.sql to modules/
Tero Marttila <terom@fixme.fi>
parents:
133
diff
changeset
|
183 |
/** |
130
ffefb6d85ea6
implement logwatch_filter::format using str_format
Tero Marttila <terom@fixme.fi>
parents:
127
diff
changeset
|
184 |
* Add a new filter. |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
185 |
* |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
186 |
* The given logwatch_chan should be a new reference. |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
187 |
*/ |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
188 |
struct logwatch_filter* logwatch_filter (struct logwatch *ctx, const char *name, const struct logwatch_source *source, |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
189 |
const char *pattern, const char *format, struct logwatch_chan *chan, struct error_info *err); |
119
64f50072db9e
add logwatch module, that can already open FIFOs
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
190 |
|
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
191 |
/** |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
192 |
* Destroy a logwatch_filter, unregistering it |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
193 |
*/ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
194 |
void logwatch_filter_destroy (struct logwatch_filter *filter); |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
119
diff
changeset
|
195 |
|
127
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
196 |
/** |
138
a716c621cb90
implement blackhole filters for logwatch, and stop applying filters after the first hit
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
197 |
* Pass the given line (from the given source) through the given filter. |
a716c621cb90
implement blackhole filters for logwatch, and stop applying filters after the first hit
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
198 |
* |
a716c621cb90
implement blackhole filters for logwatch, and stop applying filters after the first hit
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
199 |
* Returns 0 if the next filter should be tried, >0 if no more filters should be processed, and -err_t on error. |
127
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
200 |
*/ |
138
a716c621cb90
implement blackhole filters for logwatch, and stop applying filters after the first hit
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
201 |
int logwatch_filter_apply (const struct logwatch_filter *filter, const struct logwatch_source *source, const char *line, struct error_info *err); |
127
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
202 |
|
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
203 |
/** |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
204 |
* Remove any filters registered with the given source |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
205 |
*/ |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
206 |
void logwatch_filter_remove (struct logwatch *ctx, const struct logwatch_source *source); |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
207 |
|
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
208 |
/** |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
209 |
* Handle a line from the given source by applying it to all filters. |
127
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
210 |
*/ |
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
211 |
void logwatch_on_line (struct logwatch *ctx, const struct logwatch_source *source, const char *line); |
94e6c3b4230f
implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
212 |
|
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
213 |
/** |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
214 |
* Handle a disasterous error on a logwatch_source by notifying any irc_chan's that it is linked to via our filters. |
133
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
215 |
* |
e2d0c0c23b39
implement logwatch_chan.c, logwatch_chan_msg, logwatch_on_error
Tero Marttila <terom@fixme.fi>
parents:
132
diff
changeset
|
216 |
* The logwatch_source will dispose of itself after this. |
132
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
217 |
*/ |
f2ece471fb07
implement logwatch_source names, and logwatch_chan
Tero Marttila <terom@fixme.fi>
parents:
130
diff
changeset
|
218 |
void logwatch_on_error (struct logwatch *ctx, const struct logwatch_source *source, const struct error_info *err); |