diff options
author | Alexander Chemeris <Alexander.Chemeris@gmail.com> | 2015-05-24 13:20:44 -0400 |
---|---|---|
committer | Alexander Chemeris <Alexander.Chemeris@gmail.com> | 2015-05-24 13:20:44 -0400 |
commit | 5721920a08eb7414799f06bfbbfc3cc8ba6cb359 (patch) | |
tree | 3873bc4ba39eca2ed2310e26a22b558e70872d69 | |
parent | 194a9b19828f0779f7eca05ce75e2b61a776da21 (diff) |
Common: Introduce a global variable to disable syslog logging.
When we enable DEBUG logging level, syslog gets Gb's of data and can completely
exhaust the file system free space. Now we can just enable it. This is not to
say that logging to syslog it just not very useful in general.
-rw-r--r-- | CommonLibs/Logger.cpp | 16 | ||||
-rw-r--r-- | CommonLibs/Logger.h | 3 |
2 files changed, 11 insertions, 8 deletions
diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp index 06e91f6..2da802e 100644 --- a/CommonLibs/Logger.cpp +++ b/CommonLibs/Logger.cpp @@ -67,7 +67,8 @@ const char *levelNames[] = { "EMERG", "ALERT", "CRIT", "ERR", "WARNING", "NOTICE", "INFO", "DEBUG" }; int numLevels = 8; -bool gLogToConsole = 0; +bool gLogToConsole = false; +bool gLogToSyslog = true; FILE *gLogToFile = NULL; Mutex gLogToLock; @@ -196,10 +197,12 @@ Log::~Log() if (sLoggerInited) addAlarm(mStream.str().c_str()); cerr << mStream.str() << endl; } - // Current logging level was already checked by the macro. - // So just log. - syslog(mPriority, "%s", mStream.str().c_str()); - // pat added for easy debugging. + // Current logging level was already checked by the macro. So just log. + // Log to syslog + if (gLogToSyslog) { + syslog(mPriority, "%s", mStream.str().c_str()); + } + // Log to file and console if (gLogToConsole||gLogToFile) { int mlen = mStream.str().size(); int neednl = (mlen==0 || mStream.str()[mlen-1] != '\n'); @@ -243,10 +246,9 @@ void gLogInit(const char* name, const char* level, int facility) gConfig.set("Log.Level",level); } - // Pat added, tired of the syslog facility. // Both the transceiver and OpenBTS use this same facility, but only OpenBTS/OpenNodeB may use this log file: string str = gConfig.getStr("Log.File"); - if (gLogToFile==0 && str.length() && 0==strncmp(gCmdName,"Open",4)) { + if (gLogToFile==NULL && str.length() && 0==strncmp(gCmdName,"Open",4)) { const char *fn = str.c_str(); if (fn && *fn && strlen(fn)>3) { // strlen because a garbage char is getting in sometimes. gLogToFile = fopen(fn,"w"); // New log file each time we start. diff --git a/CommonLibs/Logger.h b/CommonLibs/Logger.h index 58dfa22..9667f36 100644 --- a/CommonLibs/Logger.h +++ b/CommonLibs/Logger.h @@ -116,7 +116,8 @@ class Log { std::ostringstream& get(); }; -extern bool gLogToConsole; // Pat added for easy debugging. +extern bool gLogToConsole; // Output log messages to stdout +extern bool gLogToSyslog; // Output log messages to syslog |