diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2010-01-11 06:40:15 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2010-01-11 06:40:15 +0000 |
commit | ef71cd3fc87017bde947092f6497a6bed6c41732 (patch) | |
tree | a6e9c52da3ff2d91df0a87f766a66e5fe7f6a267 /usr.sbin | |
parent | a47132c529785bf8305ce4c99000eebf7ecf2209 (diff) |
add "log brief" and "log verbose" to change logging verbosity
like several other things in the tree.
ok reyk@ looks fine claudio@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/relayctl/parser.c | 10 | ||||
-rw-r--r-- | usr.sbin/relayctl/parser.h | 6 | ||||
-rw-r--r-- | usr.sbin/relayctl/relayctl.c | 15 | ||||
-rw-r--r-- | usr.sbin/relayd/control.c | 19 | ||||
-rw-r--r-- | usr.sbin/relayd/hce.c | 7 | ||||
-rw-r--r-- | usr.sbin/relayd/log.c | 12 | ||||
-rw-r--r-- | usr.sbin/relayd/relay.c | 7 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.c | 7 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 4 |
9 files changed, 75 insertions, 12 deletions
diff --git a/usr.sbin/relayctl/parser.c b/usr.sbin/relayctl/parser.c index b723e83143b..7c0634db9c7 100644 --- a/usr.sbin/relayctl/parser.c +++ b/usr.sbin/relayctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.22 2009/11/13 20:09:54 jsg Exp $ */ +/* $OpenBSD: parser.c,v 1.23 2010/01/11 06:40:14 jsg Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -64,6 +64,7 @@ static const struct token t_host[]; static const struct token t_rdr_id[]; static const struct token t_table_id[]; static const struct token t_host_id[]; +static const struct token t_log[]; static const struct token t_main[] = { {KEYWORD, "monitor", MONITOR, NULL}, @@ -74,6 +75,7 @@ static const struct token t_main[] = { {KEYWORD, "redirect", NONE, t_rdr}, {KEYWORD, "table", NONE, t_table}, {KEYWORD, "host", NONE, t_host}, + {KEYWORD, "log", NONE, t_log}, {ENDTOKEN, "", NONE, NULL} }; @@ -123,6 +125,12 @@ static const struct token t_host_id[] = { {ENDTOKEN, "", NONE, NULL} }; +static const struct token t_log[] = { + {KEYWORD, "verbose", LOG_VERBOSE, NULL}, + {KEYWORD, "brief", LOG_BRIEF, NULL}, + {ENDTOKEN, "", NONE, NULL} +}; + static struct parse_result res; struct parse_result * diff --git a/usr.sbin/relayctl/parser.h b/usr.sbin/relayctl/parser.h index e3b3b944025..492e5454a92 100644 --- a/usr.sbin/relayctl/parser.h +++ b/usr.sbin/relayctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.11 2009/11/13 20:09:54 jsg Exp $ */ +/* $OpenBSD: parser.h,v 1.12 2010/01/11 06:40:14 jsg Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -33,7 +33,9 @@ enum actions { SHUTDOWN, POLL, RELOAD, - MONITOR + MONITOR, + LOG_VERBOSE, + LOG_BRIEF }; struct parse_result { diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index ceb4db920ac..389f12488d5 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.40 2009/09/01 08:51:34 claudio Exp $ */ +/* $OpenBSD: relayctl.c,v 1.41 2010/01/11 06:40:14 jsg Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -102,7 +102,7 @@ main(int argc, char *argv[]) struct imsg imsg; int ctl_sock; int done = 0; - int n; + int n, verbose = 0; /* parse options */ if ((res = parse(argc - 1, argv + 1)) == NULL) @@ -184,6 +184,15 @@ main(int argc, char *argv[]) case MONITOR: imsg_compose(ibuf, IMSG_CTL_NOTIFY, 0, 0, -1, NULL, 0); break; + case LOG_VERBOSE: + verbose = 2; + /* FALLTHROUGH */ + case LOG_BRIEF: + imsg_compose(ibuf, IMSG_CTL_LOG_VERBOSE, 0, 0, -1, + &verbose, sizeof(verbose)); + printf("logging request sent.\n"); + done = 1; + break; } while (ibuf->w.queued) @@ -224,6 +233,8 @@ main(int argc, char *argv[]) done = show_command_output(&imsg); break; case NONE: + case LOG_VERBOSE: + case LOG_BRIEF: break; case MONITOR: done = monitor(&imsg); diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c index 66ee4bfc5ce..b205b93d3b0 100644 --- a/usr.sbin/relayd/control.c +++ b/usr.sbin/relayd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.33 2009/12/02 19:10:02 mk Exp $ */ +/* $OpenBSD: control.c,v 1.34 2010/01/11 06:40:14 jsg Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -196,6 +196,7 @@ control_dispatch_imsg(int fd, short event, void *arg) struct imsg imsg; struct ctl_id id; int n; + int verbose; struct relayd *env = arg; if ((c = control_connbyfd(fd)) == NULL) { @@ -356,6 +357,22 @@ control_dispatch_imsg(int fd, short event, void *arg) } c->flags |= CTL_CONN_NOTIFY; break; + case IMSG_CTL_LOG_VERBOSE: + if (imsg.hdr.len != IMSG_HEADER_SIZE + + sizeof(verbose)) + break; + + memcpy(&verbose, imsg.data, sizeof(verbose)); + + imsg_compose_event(iev_hce, IMSG_CTL_LOG_VERBOSE, + 0, 0, -1, &verbose, sizeof(verbose)); + imsg_compose_event(iev_main, IMSG_CTL_LOG_VERBOSE, + 0, 0, -1, &verbose, sizeof(verbose)); + memcpy(imsg.data, &verbose, sizeof(verbose)); + control_imsg_forward(&imsg); + + log_verbose(verbose); + break; default: log_debug("control_dispatch_imsg: " "error handling imsg %d", imsg.hdr.type); diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c index f33417f44b1..96a8aac9141 100644 --- a/usr.sbin/relayd/hce.c +++ b/usr.sbin/relayd/hce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hce.c,v 1.53 2009/06/05 23:39:51 pyr Exp $ */ +/* $OpenBSD: hce.c,v 1.54 2010/01/11 06:40:14 jsg Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -368,6 +368,7 @@ hce_dispatch_imsg(int fd, short event, void *ptr) objid_t id; struct host *host; struct table *table; + int verbose; iev = ptr; ibuf = &iev->ibuf; @@ -435,6 +436,10 @@ hce_dispatch_imsg(int fd, short event, void *ptr) table->skipped = 0; hce_launch_checks(-1, EV_TIMEOUT, env); break; + case IMSG_CTL_LOG_VERBOSE: + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("hce_dispatch_msg: unexpected imsg %d", imsg.hdr.type); diff --git a/usr.sbin/relayd/log.c b/usr.sbin/relayd/log.c index 411d08c442d..d19895a113a 100644 --- a/usr.sbin/relayd/log.c +++ b/usr.sbin/relayd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.14 2008/12/05 16:37:55 reyk Exp $ */ +/* $OpenBSD: log.c,v 1.15 2010/01/11 06:40:14 jsg Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -41,6 +41,7 @@ #include "relayd.h" int debug; +int verbose; void vlog(int, const char *, va_list); void logit(int, const char *, ...); @@ -51,6 +52,7 @@ log_init(int n_debug) extern char *__progname; debug = n_debug; + verbose = n_debug; if (!debug) openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON); @@ -59,6 +61,12 @@ log_init(int n_debug) } void +log_verbose(int v) +{ + verbose = v; +} + +void logit(int pri, const char *fmt, ...) { va_list ap; @@ -137,7 +145,7 @@ log_debug(const char *emsg, ...) { va_list ap; - if (debug > 1) { + if (verbose > 1) { va_start(ap, emsg); vlog(LOG_DEBUG, emsg, ap); va_end(ap); diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 6f66788b441..0aa6d2c158a 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.117 2009/08/07 11:21:53 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.118 2010/01/11 06:40:14 jsg Exp $ */ /* * Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -2405,6 +2405,7 @@ relay_dispatch_pfe(int fd, short event, void *ptr) struct table *table; struct ctl_status st; objid_t id; + int verbose; iev = ptr; ibuf = &iev->ibuf; @@ -2508,6 +2509,10 @@ relay_dispatch_pfe(int fd, short event, void *ptr) imsg_compose_event(iev, IMSG_CTL_END, 0, 0, -1, NULL, 0); break; + case IMSG_CTL_LOG_VERBOSE: + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("relay_dispatch_msg: unexpected imsg %d", imsg.hdr.type); diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c index 7c6f9f3b84b..b0e89f61460 100644 --- a/usr.sbin/relayd/relayd.c +++ b/usr.sbin/relayd/relayd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.c,v 1.93 2009/11/11 13:09:39 jsg Exp $ */ +/* $OpenBSD: relayd.c,v 1.94 2010/01/11 06:40:14 jsg Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -617,6 +617,7 @@ main_dispatch_pfe(int fd, short event, void *ptr) struct ctl_demote demote; struct ctl_netroute crt; struct relayd *env; + int verbose; iev = ptr; ibuf = &iev->ibuf; @@ -667,6 +668,10 @@ main_dispatch_pfe(int fd, short event, void *ptr) */ reconfigure(); break; + case IMSG_CTL_LOG_VERBOSE: + memcpy(&verbose, imsg.data, sizeof(verbose)); + log_verbose(verbose); + break; default: log_debug("main_dispatch_pfe: unexpected imsg %d", imsg.hdr.type); diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 15ce555866b..878ed1e62d8 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.132 2009/11/03 21:33:22 reyk Exp $ */ +/* $OpenBSD: relayd.h,v 1.133 2010/01/11 06:40:14 jsg Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -735,6 +735,7 @@ enum imsg_type { IMSG_CTL_NOTIFY, IMSG_CTL_RDR_STATS, IMSG_CTL_RELAY_STATS, + IMSG_CTL_LOG_VERBOSE, IMSG_RDR_ENABLE, /* notifies from pfe to hce */ IMSG_RDR_DISABLE, IMSG_TABLE_ENABLE, @@ -931,6 +932,7 @@ u_int16_t shuffle_generate16(struct shuffle *); /* log.c */ void log_init(int); +void log_verbose(int); void log_warn(const char *, ...); void log_warnx(const char *, ...); void log_info(const char *, ...); |