* [PATCH btbridge v2 0/3] Add timestamps to output messages @ 2015-12-09 6:10 OpenBMC Patches 2015-12-09 6:10 ` [PATCH btbridge v2 1/3] Update usage message OpenBMC Patches ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: OpenBMC Patches @ 2015-12-09 6:10 UTC (permalink / raw) To: openbmc There have been some problems with timeouts. This should help narrow down where some of the time is going. https://github.com/openbmc/btbridge/pull/9 Cyril Bur (3): Update usage message Actually set the verbose flag with --debug Improve debugging output, timestamps and syslog btbridged.c | 59 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 14 deletions(-) -- 2.6.3 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH btbridge v2 1/3] Update usage message 2015-12-09 6:10 [PATCH btbridge v2 0/3] Add timestamps to output messages OpenBMC Patches @ 2015-12-09 6:10 ` OpenBMC Patches 2015-12-10 1:03 ` Joel Stanley 2015-12-09 6:10 ` [PATCH btbridge v2 2/3] Actually set the verbose flag with --debug OpenBMC Patches 2015-12-09 6:10 ` [PATCH btbridge v2 3/3] Improve debugging output, timestamps and syslog OpenBMC Patches 2 siblings, 1 reply; 6+ messages in thread From: OpenBMC Patches @ 2015-12-09 6:10 UTC (permalink / raw) To: openbmc; +Cc: Cyril Bur From: Cyril Bur <cyril.bur@au1.ibm.com> --- btbridged.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/btbridged.c b/btbridged.c index 115ae63..ab4880c 100644 --- a/btbridged.c +++ b/btbridged.c @@ -584,7 +584,8 @@ out: static void usage(const char *name) { - fprintf(stderr, "Usage %s\n", name); + fprintf(stderr, "Usage %s [ --debug | --verbose ]\n", name); + fprintf(stderr, "\t--debug\t Implies --verbose\n\t Dumps entire message contents to console\n"); fprintf(stderr, "\t--verbose\t Be verbose\n\n"); } -- 2.6.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH btbridge v2 1/3] Update usage message 2015-12-09 6:10 ` [PATCH btbridge v2 1/3] Update usage message OpenBMC Patches @ 2015-12-10 1:03 ` Joel Stanley 2015-12-10 4:33 ` Cyril Bur 0 siblings, 1 reply; 6+ messages in thread From: Joel Stanley @ 2015-12-10 1:03 UTC (permalink / raw) To: OpenBMC Patches; +Cc: OpenBMC Maillist, Cyril Bur On Wed, Dec 9, 2015 at 4:40 PM, OpenBMC Patches <openbmc-patches@stwcx.xyz> wrote: > From: Cyril Bur <cyril.bur@au1.ibm.com> > > --- > btbridged.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/btbridged.c b/btbridged.c > index 115ae63..ab4880c 100644 > --- a/btbridged.c > +++ b/btbridged.c > @@ -584,7 +584,8 @@ out: > > static void usage(const char *name) > { > - fprintf(stderr, "Usage %s\n", name); > + fprintf(stderr, "Usage %s [ --debug | --verbose ]\n", name); > + fprintf(stderr, "\t--debug\t Implies --verbose\n\t Dumps entire message contents to console\n"); I don't know what this means. What's the difference between debug and verbose? It might be more discoverable to support multiple levels of verbosity. -v for verbose, -vv for what you term "debug". > fprintf(stderr, "\t--verbose\t Be verbose\n\n"); > } > > -- > 2.6.3 > > > _______________________________________________ > openbmc mailing list > openbmc@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/openbmc ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH btbridge v2 1/3] Update usage message 2015-12-10 1:03 ` Joel Stanley @ 2015-12-10 4:33 ` Cyril Bur 0 siblings, 0 replies; 6+ messages in thread From: Cyril Bur @ 2015-12-10 4:33 UTC (permalink / raw) To: Joel Stanley; +Cc: OpenBMC Patches, OpenBMC Maillist On Thu, 10 Dec 2015 11:33:23 +1030 Joel Stanley <joel@jms.id.au> wrote: > On Wed, Dec 9, 2015 at 4:40 PM, OpenBMC Patches > <openbmc-patches@stwcx.xyz> wrote: > > From: Cyril Bur <cyril.bur@au1.ibm.com> > > > > --- > > btbridged.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/btbridged.c b/btbridged.c > > index 115ae63..ab4880c 100644 > > --- a/btbridged.c > > +++ b/btbridged.c > > @@ -584,7 +584,8 @@ out: > > > > static void usage(const char *name) > > { > > - fprintf(stderr, "Usage %s\n", name); > > + fprintf(stderr, "Usage %s [ --debug | --verbose ]\n", name); > > + fprintf(stderr, "\t--debug\t Implies --verbose\n\t Dumps entire message contents to console\n"); > > I don't know what this means. What's the difference between debug and verbose? > The initial idea was that verbose doesn't actually do anything but print more info. debug does actually do extra work. I agree though that from the users perspective debug just prints more... and they won't care about the distinction I'm making about added work or not. > It might be more discoverable to support multiple levels of verbosity. > -v for verbose, -vv for what you term "debug". Good idea, I'll add to pull request > > > fprintf(stderr, "\t--verbose\t Be verbose\n\n"); > > } > > > > -- > > 2.6.3 > > > > > > _______________________________________________ > > openbmc mailing list > > openbmc@lists.ozlabs.org > > https://lists.ozlabs.org/listinfo/openbmc > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH btbridge v2 2/3] Actually set the verbose flag with --debug 2015-12-09 6:10 [PATCH btbridge v2 0/3] Add timestamps to output messages OpenBMC Patches 2015-12-09 6:10 ` [PATCH btbridge v2 1/3] Update usage message OpenBMC Patches @ 2015-12-09 6:10 ` OpenBMC Patches 2015-12-09 6:10 ` [PATCH btbridge v2 3/3] Improve debugging output, timestamps and syslog OpenBMC Patches 2 siblings, 0 replies; 6+ messages in thread From: OpenBMC Patches @ 2015-12-09 6:10 UTC (permalink / raw) To: openbmc; +Cc: Cyril Bur From: Cyril Bur <cyril.bur@au1.ibm.com> --- btbridged.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/btbridged.c b/btbridged.c index ab4880c..5eccc20 100644 --- a/btbridged.c +++ b/btbridged.c @@ -624,10 +624,12 @@ int main(int argc, char *argv[]) { MSG_OUT("Found verbosity flag\n"); if (debug) { - if (!verbose) + if (!verbose) { + verbose = 1; MSG_OUT("Turning on verbosity because debug flag found\n"); - else + } else { MSG_OUT("Found debug flag\n"); + } } MSG_OUT("Starting\n"); -- 2.6.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH btbridge v2 3/3] Improve debugging output, timestamps and syslog 2015-12-09 6:10 [PATCH btbridge v2 0/3] Add timestamps to output messages OpenBMC Patches 2015-12-09 6:10 ` [PATCH btbridge v2 1/3] Update usage message OpenBMC Patches 2015-12-09 6:10 ` [PATCH btbridge v2 2/3] Actually set the verbose flag with --debug OpenBMC Patches @ 2015-12-09 6:10 ` OpenBMC Patches 2 siblings, 0 replies; 6+ messages in thread From: OpenBMC Patches @ 2015-12-09 6:10 UTC (permalink / raw) To: openbmc; +Cc: Cyril Bur From: Cyril Bur <cyril.bur@au1.ibm.com> --- btbridged.c | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/btbridged.c b/btbridged.c index 5eccc20..c2e0048 100644 --- a/btbridged.c +++ b/btbridged.c @@ -35,7 +35,7 @@ #include <systemd/sd-bus.h> -#define PREFIX "[BTBRIDGED] " +#define PREFIX "BTBRIDGED" #define BT_HOST_PATH "/dev/bt-host" #define BT_HOST_TIMEOUT_SEC 1 @@ -49,13 +49,8 @@ #define TIMER_FD 2 #define TOTAL_FDS 3 -#define MSG_OUT(f_, ...) do { if (verbose) { printf(PREFIX); printf((f_), ##__VA_ARGS__); } } while(0) -#define MSG_ERR(f_, ...) do { \ - if (verbose) { \ - fprintf(stderr, PREFIX); \ - fprintf(stderr, (f_), ##__VA_ARGS__); \ - } \ - } while(0) +#define MSG_OUT(f_, ...) do { if (verbose) { bt_log(LOG_INFO, f_, ##__VA_ARGS__); } } while(0) +#define MSG_ERR(f_, ...) do { if (verbose) { bt_log(LOG_ERR, f_, ##__VA_ARGS__); } } while(0) struct ipmi_msg { uint8_t netfn; @@ -82,10 +77,33 @@ struct btbridged_context { struct bt_queue *bt_q; }; +static void (*bt_vlog)(int p, const char *fmt, va_list args); static int running = 1; static int verbose; static int debug; +static void bt_log_console(int p, const char *fmt, va_list args) +{ + struct timespec time; + FILE *s = (p < LOG_WARNING) ? stdout : stderr; + + clock_gettime(CLOCK_REALTIME, &time); + + fprintf(s, "[%s %ld.%.9ld] ", PREFIX, time.tv_sec, time.tv_nsec); + + vfprintf(s, fmt, args); +} + +__attribute__((format(printf, 2, 3))) +static void bt_log(int p, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + bt_vlog(p, fmt, args); + va_end(args); +} + static struct bt_queue *bt_q_get_head(struct btbridged_context *context) { return context ? context->bt_q : NULL; @@ -584,9 +602,10 @@ out: static void usage(const char *name) { - fprintf(stderr, "Usage %s [ --debug | --verbose ]\n", name); + fprintf(stderr, "Usage %s [ --debug | --verbose | --syslog ]\n", name); fprintf(stderr, "\t--debug\t Implies --verbose\n\t Dumps entire message contents to console\n"); fprintf(stderr, "\t--verbose\t Be verbose\n\n"); + fprintf(stderr, "\t--syslog\t Log output to syslog (pointless without --verbose)\n"); } static const sd_bus_vtable ipmid_vtable[] = { @@ -603,17 +622,26 @@ int main(int argc, char *argv[]) { int opt, polled, r; static const struct option long_options[] = { - { "verbose", no_argument, &verbose, 1 }, - { "debug", no_argument, &debug, 1 }, - { 0, 0, 0, 0 } + { "debug", no_argument, &debug, 1 }, + { "verbose", no_argument, &verbose, 1 }, + { "syslog", no_argument, 0, 's' }, + { 0, 0, 0, 0 } }; context = calloc(1, sizeof(*context)); + bt_vlog = &bt_log_console; while ((opt = getopt_long(argc, argv, "", long_options, NULL)) != -1) { switch (opt) { case 0: break; + case 's': + /* Avoid a double openlog() */ + if (bt_vlog != &vsyslog) { + openlog(PREFIX, LOG_ODELAY, LOG_DAEMON); + bt_vlog = &vsyslog; + } + break; default: usage(name); exit(EXIT_FAILURE); -- 2.6.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-12-10 4:35 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-12-09 6:10 [PATCH btbridge v2 0/3] Add timestamps to output messages OpenBMC Patches 2015-12-09 6:10 ` [PATCH btbridge v2 1/3] Update usage message OpenBMC Patches 2015-12-10 1:03 ` Joel Stanley 2015-12-10 4:33 ` Cyril Bur 2015-12-09 6:10 ` [PATCH btbridge v2 2/3] Actually set the verbose flag with --debug OpenBMC Patches 2015-12-09 6:10 ` [PATCH btbridge v2 3/3] Improve debugging output, timestamps and syslog OpenBMC Patches
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.