equal
deleted
inserted
replaced
4 #include <stdlib.h> |
4 #include <stdlib.h> |
5 |
5 |
6 void logwatch_source_on_line (char *line, void *arg) |
6 void logwatch_source_on_line (char *line, void *arg) |
7 { |
7 { |
8 struct logwatch_source *source = arg; |
8 struct logwatch_source *source = arg; |
9 |
9 |
10 log_info("%s", line); |
10 // apply it to the logwatch's filters |
|
11 logwatch_on_line(source->ctx, source, line); |
11 } |
12 } |
12 |
13 |
13 void logwatch_source_on_error (struct error_info *err, void *arg) |
14 void logwatch_source_on_error (struct error_info *err, void *arg) |
14 { |
15 { |
15 struct logwatch_source *source = arg; |
16 struct logwatch_source *source = arg; |
|
17 |
|
18 (void) source; |
16 |
19 |
|
20 // XXX: complain more loudly |
17 log_error("%s", error_msg(err)); |
21 log_error("%s", error_msg(err)); |
18 } |
22 } |
19 |
23 |
20 static const struct line_proto_callbacks lp_callbacks = { |
24 static const struct line_proto_callbacks lp_callbacks = { |
21 .on_line = logwatch_source_on_line, |
25 .on_line = logwatch_source_on_line, |
25 /** |
29 /** |
26 * Initialize with the given sock |
30 * Initialize with the given sock |
27 */ |
31 */ |
28 err_t logwatch_source_init (struct logwatch_source *source, struct logwatch *ctx, struct sock_stream *stream, struct error_info *err) |
32 err_t logwatch_source_init (struct logwatch_source *source, struct logwatch *ctx, struct sock_stream *stream, struct error_info *err) |
29 { |
33 { |
|
34 // store |
30 source->ctx = ctx; |
35 source->ctx = ctx; |
31 |
36 |
32 // create the lp to wrap the sock |
37 // create the lp to wrap the sock |
33 if (line_proto_create(&source->lp, stream, LOGWATCH_SOURCE_LINE_MAX, &lp_callbacks, source, err)) |
38 if (line_proto_create(&source->lp, stream, LOGWATCH_SOURCE_LINE_MAX, &lp_callbacks, source, err)) |
34 goto error; |
39 goto error; |