switched to new rslog method

This commit is contained in:
sehraf 2016-06-18 13:00:15 +02:00
parent f6c5a05c8e
commit 09afbbed5d
19 changed files with 62 additions and 45 deletions

View file

@ -160,11 +160,11 @@ int locked_setDebugFile(const char *fname)
}
}
//int setOutputLevel(RsLog::logLvl lvl)
//{
// RsStackMutex stack(logMtx); /******** LOCKED ****************/
// return defaultLevel = lvl;
//}
int setOutputLevel(RsLog::logLvl lvl)
{
RsStackMutex stack(logMtx); /******** LOCKED ****************/
return defaultLevel = lvl;
}
//#ifdef deadcode // this code is not used by RS
//int setZoneLevel(int lvl, int zone)
@ -194,7 +194,7 @@ int locked_setDebugFile(const char *fname)
// return defaultLevel;
//}
void rslog(const RsLog::logLvl lvl, const RsLog::logInfo *info, const std::string &msg)
void rslog(const RsLog::logLvl lvl, RsLog::logInfo *info, const std::string &msg)
{
// skipp when log level is set to 'None'
// NB: when default is set to 'None' the later check will always fail -> no need to check it here
@ -203,7 +203,7 @@ void rslog(const RsLog::logLvl lvl, const RsLog::logInfo *info, const std::strin
RsStackMutex stack(logMtx); /******** LOCKED ****************/
bool process = info-lvl == RsLog::Default ? (lvl <= defaultLevel) : lvl <= info->lvl;
bool process = info->lvl == RsLog::Default ? (lvl <= defaultLevel) : lvl <= info->lvl;
if(process)
{
time_t t = time(NULL);
@ -235,8 +235,8 @@ void rslog(const RsLog::logLvl lvl, const RsLog::logInfo *info, const std::strin
std::string timestr = ctime(&t);
std::string timestr2 = timestr.substr(0,timestr.length()-1);
/* remove the endl */
fprintf(ofd, "(%s Z: %d, lvl:%u): %s \n",
timestr2.c_str(), zone, (unsigned int)info->lvl, msg.c_str());
fprintf(ofd, "(%s Z: %s, lvl: %u): %s \n",
timestr2.c_str(), info->name.c_str(), (unsigned int)info->lvl, msg.c_str());
fflush(ofd);
lineCount++;
}

View file

@ -30,14 +30,6 @@
#ifndef RS_LOG_DEBUG_H
#define RS_LOG_DEBUG_H
#define RSL_NONE -1
#define RSL_ALERT 1
#define RSL_ERROR 3
#define RSL_WARNING 5
#define RSL_DEBUG_ALERT 6
#define RSL_DEBUG_BASIC 8
#define RSL_DEBUG_ALL 10
#include <string>
namespace RsLog {
@ -54,13 +46,22 @@ namespace RsLog {
// this struct must be provided by the caller (to rslog())
struct logInfo {
// module name
const std::string name;
// module specific log lvl
logLvl lvl;
// module name
const std::string name;
};
}
// current RS code uses these (deprecated) defines
#define RSL_NONE RsLog::None
#define RSL_ALERT RsLog::Alert
#define RSL_ERROR RsLog::Error
#define RSL_WARNING RsLog::Warning
#define RSL_DEBUG_ALERT RsLog::Debug_Alert
#define RSL_DEBUG_BASIC RsLog::Debug_Basic
#define RSL_DEBUG_ALL RsLog::Debug_Basic
int setDebugCrashMode(const char *cfile);
//int clearDebugCrashLog();
@ -68,7 +69,7 @@ int setDebugFile(const char *fname);
int setOutputLevel(RsLog::logLvl lvl);
//int setZoneLevel(int lvl, int zone);
//int getZoneLevel(int zone);
void rslog(const RsLog::logLvl lvl, const RsLog::logInfo *info, const std::string &msg);
void rslog(const RsLog::logLvl lvl, RsLog::logInfo *info, const std::string &msg);