static struct ubus_subscriber log_event;
static struct uloop_timeout retry;
static struct uloop_fd sender;
-static const char *log_file, *log_ip, *log_port, *pid_file;
+static const char *log_file, *log_ip, *log_port, *log_prefix, *pid_file;
static int log_type = LOG_STDOUT;
static int log_size, log_udp;
{
struct blob_attr *tb[__LOG_MAX];
struct stat s;
- char buf[256];
+ char buf[512];
uint32_t p;
char *str;
time_t t;
str = blobmsg_format_json(msg, true);
if (log_type == LOG_NET) {
int err;
+ int len;
- snprintf(buf, sizeof(buf), "%s%s\n",
+ *buf = '\0';
+ if (log_prefix)
+ snprintf(buf, sizeof(buf), "%s: ", log_prefix);
+
+ len = strlen(buf);
+
+ snprintf(&buf[len], sizeof(buf) - len, "%s%s\n",
(blobmsg_get_u32(tb[LOG_SOURCE])) ? ("") : ("kernel: "),
method);
if (log_udp)
" -F <file> Log file\n"
" -S <bytes> Log size\n"
" -p <file> PID file\n"
+ " -P <prefix> Prefix custom text to streamed messages\n"
" -f Follow log messages\n"
" -u Use UDP as the protocol\n"
"\n", prog);
int ch, ret, subscribe = 0, lines = 0;
static struct blob_buf b;
- while ((ch = getopt(argc, argv, "ufcs:l:r:F:p:S:")) != -1) {
+ while ((ch = getopt(argc, argv, "ufcs:l:r:F:p:S:P:")) != -1) {
switch (ch) {
case 'u':
log_udp = 1;
case 'p':
pid_file = optarg;
break;
+ case 'P':
+ log_prefix = optarg;
+ break;
case 'f':
subscribe = 1;
break;