From e6b6e17db32247687854cacc6d6525f343b89aa9 Mon Sep 17 00:00:00 2001 From: john30 Date: Sun, 23 Apr 2017 12:08:35 +0200 Subject: [PATCH] allow logging raw bytes via command line again --- src/ebusd/main.cpp | 7 ++++--- src/ebusd/main.h | 2 +- src/ebusd/mainloop.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index 622050d6..de0282b9 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -116,7 +116,7 @@ static struct options opt = { ll_COUNT, // logLevel false, // multiLog - false, // logRaw + 0, // logRaw PACKAGE_LOGFILE, // logRawFile 100, // logRawSize @@ -216,7 +216,8 @@ static const struct argp_option argpoptions[] = { " [notice]", 0 }, {NULL, 0, NULL, 0, "Raw logging options:", 6 }, - {"lograwdata", O_RAW, NULL, 0, "Log each received/sent byte on the bus", 0 }, + {"lograwdata", O_RAW, "bytes", OPTION_ARG_OPTIONAL, + "Log messages or all received/sent bytes on the bus", 0 }, {"lograwdatafile", O_RAWFIL, "FILE", 0, "Write raw log to FILE [" PACKAGE_LOGFILE "]", 0 }, {"lograwdatasize", O_RAWSIZ, "SIZE", 0, "Make raw log file no larger than SIZE kB [100]", 0 }, @@ -504,7 +505,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) { // Raw logging options: case O_RAW: // --lograwdata - opt->logRaw = true; + opt->logRaw = arg && strcmp("bytes", arg) == 0 ? 2 : 1; break; case O_RAWFIL: // --lograwdatafile=/var/log/ebusd.log if (arg == NULL || arg[0] == 0 || strcmp("/", arg) == 0) { diff --git a/src/ebusd/main.h b/src/ebusd/main.h index 8f9af581..7bbdb0f9 100644 --- a/src/ebusd/main.h +++ b/src/ebusd/main.h @@ -74,7 +74,7 @@ struct options { LogLevel logLevel; //!< log level [notice] bool multiLog; //!< multiple log levels adjusted with --log=... - bool logRaw; //!< raw log each received/sent byte on the bus + unsigned int logRaw; //!< raw log each received/sent byte on the bus (1=messages, 2=bytes) const char* logRawFile; //!< name of raw log file [/var/log/ebusd.log] unsigned int logRawSize; //!< maximum size of raw log file in kB [100] diff --git a/src/ebusd/mainloop.cpp b/src/ebusd/mainloop.cpp index 0a9f7ac0..394b35ed 100644 --- a/src/ebusd/mainloop.cpp +++ b/src/ebusd/mainloop.cpp @@ -119,8 +119,8 @@ MainLoop::MainLoop(const struct options opt, Device *device, MessageMap* message } else { m_logRawFile = NULL; } - m_logRawEnabled = opt.logRaw; - m_logRawBytes = false; + m_logRawEnabled = opt.logRaw != 0; + m_logRawBytes = opt.logRaw == 2; m_logRawLastReceived = true; m_logRawLastSymbol = SYN; if (opt.aclFile[0]) {