static gboolean log_reader_init(LogPipe *s) { LogReader *self = (LogReader *) s; if (!log_source_init(s)) return FALSE; /* check for new data */ if (self->options->padding) { if (self->options->msg_size < self->options->padding) { msg_error("Buffer is too small to hold padding number of bytes", evt_tag_int("padding", self->options->padding), evt_tag_int("msg_size", self->options->msg_size), NULL); return FALSE; } } if (self->options->text_encoding) { if (!log_proto_set_encoding(self->proto, self->options->text_encoding)) { msg_error("Unknown character set name specified", evt_tag_str("encoding", self->options->text_encoding), NULL); return FALSE; } } if (!self->options->parse_options.format_handler) { msg_error("Unknown format plugin specified", evt_tag_str("format", self->options->parse_options.format), NULL); return FALSE; } /* the source added below references this logreader, it will be unref'd when the source is destroyed */ self->source = log_reader_watch_new(self, self->proto); g_source_attach(&self->source->super, NULL); return TRUE; }
static gboolean log_reader_init(LogPipe *s) { LogReader *self = (LogReader *) s; if (!log_source_init(s)) return FALSE; /* check for new data */ if (self->options->padding) { if (self->options->msg_size < self->options->padding) { msg_error("Buffer is too small to hold padding number of bytes", evt_tag_int("padding", self->options->padding), evt_tag_int("msg_size", self->options->msg_size), NULL); return FALSE; } } if (self->options->text_encoding) { if (!log_proto_set_encoding(self->proto, self->options->text_encoding)) { msg_error("Unknown character set name specified", evt_tag_str("encoding", self->options->text_encoding), NULL); return FALSE; } } if (!self->options->parse_options.format_handler) { msg_error("Unknown format plugin specified", evt_tag_str("format", self->options->parse_options.format), NULL); return FALSE; } if (!log_reader_start_watches(self)) return FALSE; iv_event_register(&self->schedule_wakeup); return TRUE; }