140 char *old = malloc(strlen(
log_file) + 5);
150 fprintf(stderr,
"failed to open %s: %m\n",
log_file);
159 m = blobmsg_get_string(tb[
LOG_MSG]);
161 regexec(&
regexp_preg, m, 0, NULL, 0) == REG_NOMATCH)
163 t = blobmsg_get_u64(tb[
LOG_TIME]) / 1000;
165 t_ms = blobmsg_get_u64(tb[
LOG_TIME]) % 1000;
166 snprintf(buf_ts,
sizeof(buf_ts),
"[%lu.%03u] ",
167 (
unsigned long)t, t_ms);
170 c[strlen(c) - 1] =
'\0';
175 snprintf(buf,
sizeof(buf),
"<%u>", p);
176 strncat(buf, c + 4, 16);
178 strncat(buf, buf_ts,
sizeof(buf) - strlen(buf) - 1);
181 strncat(buf,
hostname,
sizeof(buf) - strlen(buf) - 1);
182 strncat(buf,
" ",
sizeof(buf) - strlen(buf) - 1);
185 strncat(buf,
log_prefix,
sizeof(buf) - strlen(buf) - 1);
186 strncat(buf,
": ",
sizeof(buf) - strlen(buf) - 1);
189 strncat(buf,
"kernel: ",
sizeof(buf) - strlen(buf) - 1);
190 strncat(buf, m,
sizeof(buf) - strlen(buf) - 1);
192 err = write(
sender.fd, buf, strlen(buf));
194 size_t buflen = strlen(buf);
197 err = send(
sender.fd, buf, buflen + 1, 0);
201 syslog(LOG_INFO,
"Failed to send log data to %s:%s via %s\n",
206 uloop_timeout_set(&
retry, 1000);
209 snprintf(buf,
sizeof(buf),
"%s %s%s.%s%s %s\n",
213 (blobmsg_get_u32(tb[
LOG_SOURCE])) ? (
"") : (
" kernel:"), m);
214 ret = write(
sender.fd, buf, strlen(buf));
static const char * getcodetext(int value, CODE *codetable)
static regex_t regexp_preg
static int check_facility_filter(int f)
static const char * regexp_pattern
static const char * hostname
static const char * log_prefix
static const struct blobmsg_policy log_policy[]
static int log_trailer_null
static const char * log_file