diff options
author | Bill Richardson <wfrichar@chromium.org> | 2013-03-06 13:06:20 -0800 |
---|---|---|
committer | Bill Richardson <wfrichar@chromium.org> | 2013-03-06 13:20:45 -0800 |
commit | dc6ab1e4671c2b03f1a06b4388fdca408674bfe6 (patch) | |
tree | 1df7289492b36ecee0bd9de577c8e1e7c0947bbe | |
parent | ca27bcb49c20a308db62d74387142ea72bca8b05 (diff) | |
download | vboot-dc6ab1e4671c2b03f1a06b4388fdca408674bfe6.tar.gz |
Leave logging off by default.
Disable logging by default. The log file will not be created, but if it
already exists we'll add to it. So
BUG=none
BRANCH=none
TEST=manual
No logging:
rm -f /tmp/futility.log
cgpt help
cat /tmp/futility.log # file should not exist
With logging:
touch /tmp/futility.log
cgpt help
cat /tmp/futility.log # file should contain stuff
Change-Id: I2629d98f65c89e636cd78f42a5bf659058a002ae
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44755
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | futility/futility.c | 20 |
2 files changed, 12 insertions, 12 deletions
@@ -138,8 +138,8 @@ ifeq (${DISABLE_NDEBUG},) CFLAGS += -DNDEBUG endif -ifneq (${WITH_LOGGING},) -CFLAGS += -DWITH_LOGGING +ifneq (${FORCE_LOGGING_ON},) +CFLAGS += -DFORCE_LOGGING_ON=${FORCE_LOGGING_ON} endif # Create / use dependency files diff --git a/futility/futility.c b/futility/futility.c index dd70b686..90294931 100644 --- a/futility/futility.c +++ b/futility/futility.c @@ -20,10 +20,12 @@ #define MYNAME "futility" #define SUBDIR "old_bins" -/* HEY: FIXME: Hardcoding logs on for now. Delete these lines for real use. */ -#ifndef WITH_LOGGING -#define WITH_LOGGING -#endif +/* File to use for logging, if present */ +#define LOGFILE "/tmp/futility.log" + +/* Normally logging will only happen if the logfile already exists. Uncomment + * this to force log file creation (and thus logging) always. */ +/* #define FORCE_LOGGING_ON */ /******************************************************************************/ @@ -72,12 +74,9 @@ static int help(int argc, char *argv[]) DECLARE_FUTIL_COMMAND(help, help, "Show a bit of help"); -#ifdef WITH_LOGGING /******************************************************************************/ /* Logging stuff */ -#define LOGFILE "/tmp/futility.log" - static int log_fd = -1; /* Write the string and a newline. Silently give up on errors */ @@ -127,7 +126,11 @@ static void log_open(void) struct flock lock; int ret; +#ifdef FORCE_LOGGING_ON log_fd = open(LOGFILE, O_WRONLY|O_APPEND|O_CREAT, 0666); +#else + log_fd = open(LOGFILE, O_WRONLY|O_APPEND); +#endif if (log_fd < 0) { if (errno != EACCES) @@ -182,9 +185,6 @@ static void log_args(int argc, char *argv[]) log_close(); } -#else -#define log_args(...) -#endif /* WITH_LOGGING */ /******************************************************************************/ |