From 5ebf67efee2893c4d3dc60ec31a0efeb0894d245 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Fri, 5 Feb 2010 15:33:39 +0100 Subject: Added logging flag to log_append() to change log behaviour Valid flags are: * LOGFL_NORMAL Log all messages to the log context, and send log message to stderr on errors * LOGFL_NODUPS Log only unique messages. Duplicated messages will be removed * LOGFL_NOSTDERR Don't write to stderr, even if errors occur --- src/dmidecodemodule.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/dmidecodemodule.c') diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c index 93a956b..dc00279 100644 --- a/src/dmidecodemodule.c +++ b/src/dmidecodemodule.c @@ -66,7 +66,8 @@ static void init(options *opt) /* sanity check */ if(sizeof(u8) != 1 || sizeof(u16) != 2 || sizeof(u32) != 4 || '\0' != 0) { - log_append(opt->logdata, LOG_WARNING, "%s: compiler incompatibility\n", "dmidecodemodule"); + log_append(opt->logdata, LOGFL_NORMAL, LOG_WARNING, + "%s: compiler incompatibility\n", "dmidecodemodule"); } } @@ -78,11 +79,11 @@ int parse_opt_type(Log_t *logp, const char *arg) val = strtoul(arg, &next, 0); if(next == arg) { - log_append(logp, LOG_ERR, "Invalid type keyword: %s\n", arg); + log_append(logp, LOGFL_NODUPS, LOG_ERR, "Invalid type keyword: %s\n", arg); return -1; } if(val > 0xff) { - log_append(logp, LOG_ERR, "Invalid type number: %i\n", val); + log_append(logp, LOGFL_NODUPS, LOG_ERR, "Invalid type number: %i\n", val); return -1; } @@ -164,7 +165,8 @@ xmlNode *dmidecode_get_version(options *opt) free(buf); } if( !found ) { - log_append(opt->logdata, LOG_WARNING, "No SMBIOS nor DMI entry point found, sorry."); + log_append(opt->logdata, LOGFL_NODUPS, LOG_WARNING, + "No SMBIOS nor DMI entry point found, sorry."); } return ver_n; } @@ -185,7 +187,8 @@ int dmidecode_get_xml(options *opt, xmlNode* dmixml_n) const char *f = opt->dumpfile ? opt->dumpfile : opt->devmem; if(access(f, R_OK) < 0) { - log_append(opt->logdata, LOG_WARNING, "Permission denied to memory file/device (%s)", f); + log_append(opt->logdata, LOGFL_NORMAL, + LOG_WARNING, "Permission denied to memory file/device (%s)", f); return 0; } -- cgit