You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-01 06:21:41 +03:00
Reformat all code to coding standard
This commit is contained in:
@ -26,10 +26,11 @@ using namespace std;
|
||||
|
||||
#include "errorcodes.h"
|
||||
|
||||
namespace logging {
|
||||
namespace logging
|
||||
{
|
||||
|
||||
ErrorCodes::ErrorCodes(): fErrorCodes(), fPreamble("An unexpected condition within the query caused an internal processing error within InfiniDB. Please check the log files for more details. Additional Information: ")
|
||||
{
|
||||
ErrorCodes::ErrorCodes(): fErrorCodes(), fPreamble("An unexpected condition within the query caused an internal processing error within InfiniDB. Please check the log files for more details. Additional Information: ")
|
||||
{
|
||||
fErrorCodes[batchPrimitiveStepErr] = "error in BatchPrimitiveStep.";
|
||||
fErrorCodes[tupleBPSErr] = "error in TupleBPS.";
|
||||
fErrorCodes[batchPrimitiveStepLargeDataListFileErr] = "error in BatchPrimitiveStep LargeDataList File handling.";
|
||||
@ -72,26 +73,27 @@ namespace logging {
|
||||
fErrorCodes[dataTypeErr] = "data type unknown.";
|
||||
fErrorCodes[incompatJoinCols] = "incompatible column types specified for join condition.";
|
||||
fErrorCodes[incompatFilterCols] = "incompatible column types specified for filter condition.";
|
||||
}
|
||||
}
|
||||
|
||||
string ErrorCodes::errorString(uint16_t code) const
|
||||
{
|
||||
string ErrorCodes::errorString(uint16_t code) const
|
||||
{
|
||||
CodeMap::const_iterator iter;
|
||||
CodeMap::key_type key = static_cast<CodeMap::key_type>(code);
|
||||
CodeMap::mapped_type msg;
|
||||
|
||||
iter = fErrorCodes.find(key);
|
||||
|
||||
if (iter == fErrorCodes.end())
|
||||
{
|
||||
msg = "was an unknown internal error.";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = iter->second;
|
||||
msg = iter->second;
|
||||
}
|
||||
|
||||
return (fPreamble + msg);
|
||||
}
|
||||
}
|
||||
} //namespace logging
|
||||
// vim:ts=4 sw=4:
|
||||
|
||||
|
@ -29,70 +29,70 @@
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace logging
|
||||
{
|
||||
namespace logging
|
||||
{
|
||||
|
||||
enum ErrorCodeValues
|
||||
{
|
||||
batchPrimitiveStepErr = 1,
|
||||
tupleBPSErr,
|
||||
batchPrimitiveStepLargeDataListFileErr,
|
||||
bucketReuseStepErr,
|
||||
bucketReuseStepLargeDataListFileErr,
|
||||
aggregateFilterStepErr,
|
||||
filterStepErr,
|
||||
functionStepErr,
|
||||
hashJoinStepErr,
|
||||
hashJoinStepLargeDataListFileErr,
|
||||
largeHashJoinErr,
|
||||
largeHashJoinLargeDataListFileErr,
|
||||
stringHashJoinStepErr,
|
||||
stringHashJoinStepLargeDataListFileErr,
|
||||
tupleHashJoinTooBigErr,
|
||||
threadResourceErr,
|
||||
pDictionaryScanErr,
|
||||
pDictionaryScanLargeDataListFileErr,
|
||||
pIdxListErr,
|
||||
pIdxWalkErr,
|
||||
pnlJoinErr,
|
||||
reduceStepErr,
|
||||
reduceStepLargeDataListFileErr,
|
||||
unionStepErr,
|
||||
unionStepLargeDataListFileErr,
|
||||
unionStepTooBigErr,
|
||||
tupleAggregateStepErr,
|
||||
tupleConstantStepErr,
|
||||
tupleHavingStepErr,
|
||||
makeJobListErr,
|
||||
aggregateFuncErr,
|
||||
aggregateDataErr,
|
||||
batchPrimitiveStepErr = 1,
|
||||
tupleBPSErr,
|
||||
batchPrimitiveStepLargeDataListFileErr,
|
||||
bucketReuseStepErr,
|
||||
bucketReuseStepLargeDataListFileErr,
|
||||
aggregateFilterStepErr,
|
||||
filterStepErr,
|
||||
functionStepErr,
|
||||
hashJoinStepErr,
|
||||
hashJoinStepLargeDataListFileErr,
|
||||
largeHashJoinErr,
|
||||
largeHashJoinLargeDataListFileErr,
|
||||
stringHashJoinStepErr,
|
||||
stringHashJoinStepLargeDataListFileErr,
|
||||
tupleHashJoinTooBigErr,
|
||||
threadResourceErr,
|
||||
pDictionaryScanErr,
|
||||
pDictionaryScanLargeDataListFileErr,
|
||||
pIdxListErr,
|
||||
pIdxWalkErr,
|
||||
pnlJoinErr,
|
||||
reduceStepErr,
|
||||
reduceStepLargeDataListFileErr,
|
||||
unionStepErr,
|
||||
unionStepLargeDataListFileErr,
|
||||
unionStepTooBigErr,
|
||||
tupleAggregateStepErr,
|
||||
tupleConstantStepErr,
|
||||
tupleHavingStepErr,
|
||||
makeJobListErr,
|
||||
aggregateFuncErr,
|
||||
aggregateDataErr,
|
||||
//don't use 100, same as SQL_NOT_FOUND
|
||||
batchPrimitiveProcessorErr = 101,
|
||||
bppSeederErr,
|
||||
primitiveServerErr,
|
||||
projectResultErr,
|
||||
hwmRangeSizeErr,
|
||||
// user input data error
|
||||
formatErr = 201,
|
||||
dataTypeErr,
|
||||
incompatJoinCols,
|
||||
incompatFilterCols,
|
||||
aggregateResourceErr
|
||||
batchPrimitiveProcessorErr = 101,
|
||||
bppSeederErr,
|
||||
primitiveServerErr,
|
||||
projectResultErr,
|
||||
hwmRangeSizeErr,
|
||||
// user input data error
|
||||
formatErr = 201,
|
||||
dataTypeErr,
|
||||
incompatJoinCols,
|
||||
incompatFilterCols,
|
||||
aggregateResourceErr
|
||||
};
|
||||
|
||||
struct ErrorCodes
|
||||
{
|
||||
ErrorCodes();
|
||||
std::string errorString(uint16_t code) const;
|
||||
ErrorCodes();
|
||||
std::string errorString(uint16_t code) const;
|
||||
private:
|
||||
typedef std::map<ErrorCodeValues, std::string> CodeMap;
|
||||
typedef std::map<ErrorCodeValues, std::string> CodeMap;
|
||||
|
||||
//defaults okay
|
||||
//ErrorCodes(const ErrorCodes& rhs);
|
||||
//ErrorCodes& operator=(const ErrorCodes& rhs);
|
||||
//defaults okay
|
||||
//ErrorCodes(const ErrorCodes& rhs);
|
||||
//ErrorCodes& operator=(const ErrorCodes& rhs);
|
||||
|
||||
CodeMap fErrorCodes;
|
||||
const std::string fPreamble;
|
||||
CodeMap fErrorCodes;
|
||||
const std::string fPreamble;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -45,32 +45,38 @@ namespace logging
|
||||
class IDBExcept : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
IDBExcept(uint16_t code) :
|
||||
std::runtime_error(IDBErrorInfo::instance()->errorMsg(code)), fErrCode(code) {}
|
||||
IDBExcept(uint16_t code, const Message::Args& args) :
|
||||
std::runtime_error(IDBErrorInfo::instance()->errorMsg(code, args)), fErrCode(code){}
|
||||
IDBExcept(const std::string& msg, uint16_t code) :
|
||||
std::runtime_error(msg), fErrCode(code){ }
|
||||
void errorCode(uint16_t code) { fErrCode = code; }
|
||||
uint16_t errorCode() const { return fErrCode; }
|
||||
IDBExcept(uint16_t code) :
|
||||
std::runtime_error(IDBErrorInfo::instance()->errorMsg(code)), fErrCode(code) {}
|
||||
IDBExcept(uint16_t code, const Message::Args& args) :
|
||||
std::runtime_error(IDBErrorInfo::instance()->errorMsg(code, args)), fErrCode(code) {}
|
||||
IDBExcept(const std::string& msg, uint16_t code) :
|
||||
std::runtime_error(msg), fErrCode(code) { }
|
||||
void errorCode(uint16_t code)
|
||||
{
|
||||
fErrCode = code;
|
||||
}
|
||||
uint16_t errorCode() const
|
||||
{
|
||||
return fErrCode;
|
||||
}
|
||||
protected:
|
||||
unsigned fErrCode;
|
||||
unsigned fErrCode;
|
||||
};
|
||||
|
||||
class DictionaryBufferOverflow : public IDBExcept
|
||||
{
|
||||
public:
|
||||
DictionaryBufferOverflow() : IDBExcept(ERR_DICTBUFFER_OVERFLOW)
|
||||
{ }
|
||||
DictionaryBufferOverflow() : IDBExcept(ERR_DICTBUFFER_OVERFLOW)
|
||||
{ }
|
||||
};
|
||||
|
||||
class LargeDataListExcept : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
/** Takes a character string describing the error. */
|
||||
explicit LargeDataListExcept(const std::string& msg) : std::runtime_error(msg) { }
|
||||
/** Takes a character string describing the error. */
|
||||
explicit LargeDataListExcept(const std::string& msg) : std::runtime_error(msg) { }
|
||||
|
||||
virtual ~LargeDataListExcept() throw() { }
|
||||
virtual ~LargeDataListExcept() throw() { }
|
||||
};
|
||||
|
||||
|
||||
@ -81,15 +87,15 @@ public:
|
||||
class QueryDataExcept : public IDBExcept
|
||||
{
|
||||
public:
|
||||
/** Takes a character string describing the error. */
|
||||
QueryDataExcept(const std::string& msg, uint16_t code) :
|
||||
IDBExcept(msg, code) { }
|
||||
/** Takes a character string describing the error. */
|
||||
QueryDataExcept(const std::string& msg, uint16_t code) :
|
||||
IDBExcept(msg, code) { }
|
||||
|
||||
virtual ~QueryDataExcept() throw() { }
|
||||
virtual ~QueryDataExcept() throw() { }
|
||||
private:
|
||||
//defaults okay
|
||||
//QueryDataExcept(const QueryDataExcept& rhs);
|
||||
//QueryDataExcept& operator=(const QueryDataExcept& rhs);
|
||||
//defaults okay
|
||||
//QueryDataExcept(const QueryDataExcept& rhs);
|
||||
//QueryDataExcept& operator=(const QueryDataExcept& rhs);
|
||||
};
|
||||
|
||||
/** @brief specific error exception class for VBBM Version Buffer overflow
|
||||
@ -99,14 +105,17 @@ private:
|
||||
class VBBMBufferOverFlowExcept : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
/** Takes a character string describing the error. */
|
||||
VBBMBufferOverFlowExcept(const std::string& msg) :
|
||||
std::runtime_error(msg), fErrorCode(8) { }
|
||||
//ERR_VBBM_OVERFLOW = 8 defined in brmtypes.h
|
||||
int8_t errorCode() const { return fErrorCode; }
|
||||
/** Takes a character string describing the error. */
|
||||
VBBMBufferOverFlowExcept(const std::string& msg) :
|
||||
std::runtime_error(msg), fErrorCode(8) { }
|
||||
//ERR_VBBM_OVERFLOW = 8 defined in brmtypes.h
|
||||
int8_t errorCode() const
|
||||
{
|
||||
return fErrorCode;
|
||||
}
|
||||
|
||||
private:
|
||||
int8_t fErrorCode;
|
||||
int8_t fErrorCode;
|
||||
};
|
||||
|
||||
/** @brief specific error exception class for VBBM Version Buffer overflow
|
||||
@ -116,9 +125,9 @@ private:
|
||||
class PrimitiveColumnProjectResultExcept : public QueryDataExcept
|
||||
{
|
||||
public:
|
||||
/** Takes a character string describing the error. */
|
||||
PrimitiveColumnProjectResultExcept(const std::string& msg) :
|
||||
QueryDataExcept(msg, projectResultErr) { }
|
||||
/** Takes a character string describing the error. */
|
||||
PrimitiveColumnProjectResultExcept(const std::string& msg) :
|
||||
QueryDataExcept(msg, projectResultErr) { }
|
||||
};
|
||||
|
||||
/** @brief specific error exception class for PrimProc invalid HWM
|
||||
@ -128,9 +137,9 @@ public:
|
||||
class InvalidRangeHWMExcept : public QueryDataExcept
|
||||
{
|
||||
public:
|
||||
/** Takes a character string describing the error. */
|
||||
InvalidRangeHWMExcept(const std::string& msg) :
|
||||
QueryDataExcept(msg, hwmRangeSizeErr){ }
|
||||
/** Takes a character string describing the error. */
|
||||
InvalidRangeHWMExcept(const std::string& msg) :
|
||||
QueryDataExcept(msg, hwmRangeSizeErr) { }
|
||||
};
|
||||
|
||||
|
||||
@ -140,9 +149,9 @@ public:
|
||||
class InvalidOperationExcept : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
/** Takes a character string describing the error. */
|
||||
InvalidOperationExcept(const std::string& msg) :
|
||||
std::runtime_error(msg){ }
|
||||
/** Takes a character string describing the error. */
|
||||
InvalidOperationExcept(const std::string& msg) :
|
||||
std::runtime_error(msg) { }
|
||||
};
|
||||
|
||||
/** @brief Exception for F&E framework to throw
|
||||
@ -151,9 +160,9 @@ public:
|
||||
class InvalidConversionExcept : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
/** Takes a character string describing the error. */
|
||||
InvalidConversionExcept(const std::string& msg) :
|
||||
std::runtime_error(msg){ }
|
||||
/** Takes a character string describing the error. */
|
||||
InvalidConversionExcept(const std::string& msg) :
|
||||
std::runtime_error(msg) { }
|
||||
};
|
||||
|
||||
/** @brief Exception for F&E framework -- function evaluation to throw
|
||||
@ -162,9 +171,9 @@ public:
|
||||
class InvalidArgumentExcept : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
/** Takes a character string describing the error. */
|
||||
InvalidArgumentExcept(const std::string& msg) :
|
||||
std::runtime_error(msg){ }
|
||||
/** Takes a character string describing the error. */
|
||||
InvalidArgumentExcept(const std::string& msg) :
|
||||
std::runtime_error(msg) { }
|
||||
};
|
||||
|
||||
/** @brief Exception for F&E framework -- function evaluation to throw
|
||||
@ -173,9 +182,9 @@ public:
|
||||
class NotImplementedExcept : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
/** Takes a character string describing the error. */
|
||||
NotImplementedExcept(const std::string& msg) :
|
||||
std::runtime_error(msg){ }
|
||||
/** Takes a character string describing the error. */
|
||||
NotImplementedExcept(const std::string& msg) :
|
||||
std::runtime_error(msg) { }
|
||||
};
|
||||
|
||||
/** @brief specific error exception class for getSysData in Calpontsystemcatalog.
|
||||
@ -185,38 +194,38 @@ public:
|
||||
class NoTableExcept : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
/** Takes a character string describing the error. */
|
||||
NoTableExcept(const std::string& msg) :
|
||||
std::runtime_error(msg){ }
|
||||
/** Takes a character string describing the error. */
|
||||
NoTableExcept(const std::string& msg) :
|
||||
std::runtime_error(msg) { }
|
||||
};
|
||||
|
||||
class MoreThan1RowExcept : public IDBExcept
|
||||
{
|
||||
public:
|
||||
MoreThan1RowExcept() :
|
||||
IDBExcept(ERR_MORE_THAN_1_ROW)
|
||||
{ }
|
||||
MoreThan1RowExcept() :
|
||||
IDBExcept(ERR_MORE_THAN_1_ROW)
|
||||
{ }
|
||||
};
|
||||
|
||||
class CorrelateFailExcept : public IDBExcept
|
||||
{
|
||||
public:
|
||||
CorrelateFailExcept() :
|
||||
IDBExcept(ERR_CORRELATE_FAIL)
|
||||
{ }
|
||||
CorrelateFailExcept() :
|
||||
IDBExcept(ERR_CORRELATE_FAIL)
|
||||
{ }
|
||||
};
|
||||
|
||||
class DBRMException : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
DBRMException(const std::string& emsg) :
|
||||
std::runtime_error(emsg) {}
|
||||
DBRMException(const std::string& emsg) :
|
||||
std::runtime_error(emsg) {}
|
||||
};
|
||||
|
||||
class ProtocolError : public std::logic_error
|
||||
{
|
||||
public:
|
||||
ProtocolError(const std::string &emsg) : std::logic_error(emsg) { }
|
||||
ProtocolError(const std::string& emsg) : std::logic_error(emsg) { }
|
||||
};
|
||||
|
||||
#ifndef __STRING
|
||||
|
@ -42,58 +42,71 @@ using namespace config;
|
||||
|
||||
#include "installdir.h"
|
||||
|
||||
namespace logging {
|
||||
namespace logging
|
||||
{
|
||||
|
||||
IDBErrorInfo* IDBErrorInfo::fInstance = 0;
|
||||
mutex mx;
|
||||
|
||||
IDBErrorInfo* IDBErrorInfo::instance()
|
||||
{
|
||||
mutex::scoped_lock lk(mx);
|
||||
if (!fInstance)
|
||||
fInstance = new IDBErrorInfo();
|
||||
return fInstance;
|
||||
mutex::scoped_lock lk(mx);
|
||||
|
||||
if (!fInstance)
|
||||
fInstance = new IDBErrorInfo();
|
||||
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
IDBErrorInfo::IDBErrorInfo()
|
||||
{
|
||||
Config* cf = Config::makeConfig();
|
||||
string configFile(cf->getConfig("SystemConfig", "ErrorMessageFile"));
|
||||
if (configFile.length() == 0)
|
||||
configFile = startup::StartUp::installDir() + "/etc/ErrorMessage.txt";
|
||||
ifstream msgFile(configFile.c_str());
|
||||
while (msgFile.good())
|
||||
{
|
||||
stringbuf* sb = new stringbuf;
|
||||
msgFile.get(*sb);
|
||||
string m = sb->str();
|
||||
delete sb;
|
||||
if (m.length() > 0 && m[0] != '#')
|
||||
{
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep("\t");
|
||||
tokenizer tokens(m, sep);
|
||||
tokenizer::iterator tok_iter = tokens.begin();
|
||||
if (tok_iter != tokens.end())
|
||||
{
|
||||
int msgid = atoi(tok_iter->c_str());
|
||||
++tok_iter;
|
||||
if (tok_iter != tokens.end())
|
||||
{
|
||||
++tok_iter;
|
||||
if (tok_iter != tokens.end())
|
||||
{
|
||||
string msgtext = *tok_iter;
|
||||
fErrMap[msgid] = msgtext;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ios_base::iostate st = msgFile.rdstate();
|
||||
if ((st & ios_base::failbit) && !(st & ios_base::eofbit))
|
||||
msgFile.clear();
|
||||
(void)msgFile.get();
|
||||
}
|
||||
Config* cf = Config::makeConfig();
|
||||
string configFile(cf->getConfig("SystemConfig", "ErrorMessageFile"));
|
||||
|
||||
if (configFile.length() == 0)
|
||||
configFile = startup::StartUp::installDir() + "/etc/ErrorMessage.txt";
|
||||
|
||||
ifstream msgFile(configFile.c_str());
|
||||
|
||||
while (msgFile.good())
|
||||
{
|
||||
stringbuf* sb = new stringbuf;
|
||||
msgFile.get(*sb);
|
||||
string m = sb->str();
|
||||
delete sb;
|
||||
|
||||
if (m.length() > 0 && m[0] != '#')
|
||||
{
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep("\t");
|
||||
tokenizer tokens(m, sep);
|
||||
tokenizer::iterator tok_iter = tokens.begin();
|
||||
|
||||
if (tok_iter != tokens.end())
|
||||
{
|
||||
int msgid = atoi(tok_iter->c_str());
|
||||
++tok_iter;
|
||||
|
||||
if (tok_iter != tokens.end())
|
||||
{
|
||||
++tok_iter;
|
||||
|
||||
if (tok_iter != tokens.end())
|
||||
{
|
||||
string msgtext = *tok_iter;
|
||||
fErrMap[msgid] = msgtext;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ios_base::iostate st = msgFile.rdstate();
|
||||
|
||||
if ((st & ios_base::failbit) && !(st & ios_base::eofbit))
|
||||
msgFile.clear();
|
||||
|
||||
(void)msgFile.get();
|
||||
}
|
||||
}
|
||||
|
||||
IDBErrorInfo::~IDBErrorInfo()
|
||||
@ -102,99 +115,102 @@ IDBErrorInfo::~IDBErrorInfo()
|
||||
|
||||
string IDBErrorInfo::errorMsg(const unsigned eid, const Message::Args& args)
|
||||
{
|
||||
string errMsg = lookupError(eid);
|
||||
format(errMsg, args);
|
||||
return errMsg;
|
||||
string errMsg = lookupError(eid);
|
||||
format(errMsg, args);
|
||||
return errMsg;
|
||||
}
|
||||
|
||||
string IDBErrorInfo::errorMsg(const unsigned eid)
|
||||
{
|
||||
string errMsg = lookupError(eid);
|
||||
Message::Args args; // empty args
|
||||
format(errMsg, args);
|
||||
return errMsg;
|
||||
string errMsg = lookupError(eid);
|
||||
Message::Args args; // empty args
|
||||
format(errMsg, args);
|
||||
return errMsg;
|
||||
}
|
||||
|
||||
string IDBErrorInfo::errorMsg(const unsigned eid, int i)
|
||||
{
|
||||
string errMsg = lookupError(eid);
|
||||
Message::Args args;
|
||||
args.add(i);
|
||||
format(errMsg, args);
|
||||
return errMsg;
|
||||
string errMsg = lookupError(eid);
|
||||
Message::Args args;
|
||||
args.add(i);
|
||||
format(errMsg, args);
|
||||
return errMsg;
|
||||
}
|
||||
|
||||
string IDBErrorInfo::errorMsg(const unsigned eid, const string& s)
|
||||
{
|
||||
string errMsg = lookupError(eid);
|
||||
Message::Args args;
|
||||
args.add(s);
|
||||
format(errMsg, args);
|
||||
return errMsg;
|
||||
string errMsg = lookupError(eid);
|
||||
Message::Args args;
|
||||
args.add(s);
|
||||
format(errMsg, args);
|
||||
return errMsg;
|
||||
}
|
||||
|
||||
string IDBErrorInfo::logError(const logging::LOG_TYPE logLevel,
|
||||
const logging::LoggingID logid,
|
||||
const unsigned eid,
|
||||
const logging::Message::Args& args)
|
||||
const logging::LoggingID logid,
|
||||
const unsigned eid,
|
||||
const logging::Message::Args& args)
|
||||
{
|
||||
Logger logger(logid.fSubsysID);
|
||||
Message message(errorMsg(eid, args));
|
||||
return logger.logMessage(logLevel, message, logid);
|
||||
}
|
||||
Logger logger(logid.fSubsysID);
|
||||
Message message(errorMsg(eid, args));
|
||||
return logger.logMessage(logLevel, message, logid);
|
||||
}
|
||||
|
||||
void IDBErrorInfo::format(string& errMsg, const Message::Args& args)
|
||||
{
|
||||
Message::Args::AnyVec::const_iterator iter = args.args().begin();
|
||||
Message::Args::AnyVec::const_iterator end = args.args().end();
|
||||
Message::Args::AnyVec::const_iterator iter = args.args().begin();
|
||||
Message::Args::AnyVec::const_iterator end = args.args().end();
|
||||
|
||||
boost::format fmt(errMsg);
|
||||
fmt.exceptions(boost::io::no_error_bits);
|
||||
boost::format fmt(errMsg);
|
||||
fmt.exceptions(boost::io::no_error_bits);
|
||||
|
||||
while (iter != end)
|
||||
{
|
||||
if (iter->type() == typeid(long))
|
||||
{
|
||||
long l = any_cast<long>(*iter);
|
||||
fmt % l;
|
||||
}
|
||||
else if (iter->type() == typeid(uint64_t))
|
||||
{
|
||||
uint64_t u64 = any_cast<uint64_t>(*iter);
|
||||
fmt % u64;
|
||||
}
|
||||
else if (iter->type() == typeid(double))
|
||||
{
|
||||
double d = any_cast<double>(*iter);
|
||||
fmt % d;
|
||||
}
|
||||
else if (iter->type() == typeid(string))
|
||||
{
|
||||
string s = any_cast<string>(*iter);
|
||||
fmt % s;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw logic_error("IDBErrorInfo::format: unexpected type in argslist");
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
while (iter != end)
|
||||
{
|
||||
if (iter->type() == typeid(long))
|
||||
{
|
||||
long l = any_cast<long>(*iter);
|
||||
fmt % l;
|
||||
}
|
||||
else if (iter->type() == typeid(uint64_t))
|
||||
{
|
||||
uint64_t u64 = any_cast<uint64_t>(*iter);
|
||||
fmt % u64;
|
||||
}
|
||||
else if (iter->type() == typeid(double))
|
||||
{
|
||||
double d = any_cast<double>(*iter);
|
||||
fmt % d;
|
||||
}
|
||||
else if (iter->type() == typeid(string))
|
||||
{
|
||||
string s = any_cast<string>(*iter);
|
||||
fmt % s;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw logic_error("IDBErrorInfo::format: unexpected type in argslist");
|
||||
}
|
||||
|
||||
errMsg = fmt.str();
|
||||
++iter;
|
||||
}
|
||||
|
||||
errMsg = fmt.str();
|
||||
}
|
||||
|
||||
/* static */
|
||||
string IDBErrorInfo::lookupError(const unsigned eid)
|
||||
{
|
||||
string msgstr;
|
||||
ErrorMap::const_iterator iter = fErrMap.find(eid);
|
||||
if (iter == fErrMap.end())
|
||||
msgstr = "Unknown Error %1% %2% %3% %4% %5%";
|
||||
else
|
||||
msgstr = iter->second;
|
||||
ostringstream oss;
|
||||
oss << "IDB-" << setw(4) << setfill('0') << eid << ": " << msgstr;
|
||||
return oss.str();
|
||||
string msgstr;
|
||||
ErrorMap::const_iterator iter = fErrMap.find(eid);
|
||||
|
||||
if (iter == fErrMap.end())
|
||||
msgstr = "Unknown Error %1% %2% %3% %4% %5%";
|
||||
else
|
||||
msgstr = iter->second;
|
||||
|
||||
ostringstream oss;
|
||||
oss << "IDB-" << setw(4) << setfill('0') << eid << ": " << msgstr;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,8 @@
|
||||
#include "messageobj.h"
|
||||
#include "messagelog.h"
|
||||
|
||||
namespace logging {
|
||||
namespace logging
|
||||
{
|
||||
|
||||
/** @brief an IDB error info class
|
||||
*
|
||||
@ -43,23 +44,23 @@ typedef std::map<unsigned, std::string> ErrorMap;
|
||||
class IDBErrorInfo
|
||||
{
|
||||
public:
|
||||
static IDBErrorInfo* instance();
|
||||
std::string errorMsg(const unsigned eid, const Message::Args& args);
|
||||
std::string errorMsg(const unsigned eid);
|
||||
std::string errorMsg(const unsigned eid, int i);
|
||||
std::string errorMsg(const unsigned eid, const std::string& s);
|
||||
std::string logError(const logging::LOG_TYPE logLevel,
|
||||
const LoggingID logid,
|
||||
const unsigned eid,
|
||||
const Message::Args& args);
|
||||
~IDBErrorInfo();
|
||||
static IDBErrorInfo* instance();
|
||||
std::string errorMsg(const unsigned eid, const Message::Args& args);
|
||||
std::string errorMsg(const unsigned eid);
|
||||
std::string errorMsg(const unsigned eid, int i);
|
||||
std::string errorMsg(const unsigned eid, const std::string& s);
|
||||
std::string logError(const logging::LOG_TYPE logLevel,
|
||||
const LoggingID logid,
|
||||
const unsigned eid,
|
||||
const Message::Args& args);
|
||||
~IDBErrorInfo();
|
||||
|
||||
private:
|
||||
static IDBErrorInfo* fInstance;
|
||||
ErrorMap fErrMap;
|
||||
IDBErrorInfo();
|
||||
void format(std::string& messageFormat, const Message::Args& args);
|
||||
std::string lookupError(const unsigned eid);
|
||||
static IDBErrorInfo* fInstance;
|
||||
ErrorMap fErrMap;
|
||||
IDBErrorInfo();
|
||||
void format(std::string& messageFormat, const Message::Args& args);
|
||||
std::string lookupError(const unsigned eid);
|
||||
};
|
||||
|
||||
}//namespace logging
|
||||
|
@ -30,79 +30,83 @@ namespace logging
|
||||
{
|
||||
|
||||
Logger::Logger(unsigned subsys) :
|
||||
fMl1(LoggingID(subsys))
|
||||
fMl1(LoggingID(subsys))
|
||||
{
|
||||
}
|
||||
|
||||
const string Logger::logMessage(LOG_TYPE logLevel, Message::MessageID mid, const Message::Args& args,
|
||||
const LoggingID& logInfo)
|
||||
const LoggingID& logInfo)
|
||||
{
|
||||
MsgMap::mapped_type msg;
|
||||
MsgMap::const_iterator msgIter = fMsgMap.find(mid);
|
||||
MsgMap::mapped_type msg;
|
||||
MsgMap::const_iterator msgIter = fMsgMap.find(mid);
|
||||
|
||||
//Default message if specified # not found
|
||||
if (msgIter == fMsgMap.end())
|
||||
msg = Message(M0000);
|
||||
else
|
||||
msg = msgIter->second;
|
||||
//Default message if specified # not found
|
||||
if (msgIter == fMsgMap.end())
|
||||
msg = Message(M0000);
|
||||
else
|
||||
msg = msgIter->second;
|
||||
|
||||
msg.reset();
|
||||
msg.format(args);
|
||||
msg.reset();
|
||||
msg.format(args);
|
||||
|
||||
return logMessage(logLevel, msg, logInfo);
|
||||
/*
|
||||
mutex::scoped_lock lk(fLogLock);
|
||||
fMl1.logData(logInfo);
|
||||
return logMessage(logLevel, msg, logInfo);
|
||||
/*
|
||||
mutex::scoped_lock lk(fLogLock);
|
||||
fMl1.logData(logInfo);
|
||||
|
||||
switch (logLevel)
|
||||
{
|
||||
switch (logLevel)
|
||||
{
|
||||
case LOG_TYPE_DEBUG:
|
||||
default:
|
||||
fMl1.logDebugMessage(msg);
|
||||
break;
|
||||
default:
|
||||
fMl1.logDebugMessage(msg);
|
||||
break;
|
||||
case LOG_TYPE_INFO:
|
||||
fMl1.logInfoMessage(msg);
|
||||
break;
|
||||
fMl1.logInfoMessage(msg);
|
||||
break;
|
||||
case LOG_TYPE_WARNING:
|
||||
fMl1.logWarningMessage(msg);
|
||||
break;
|
||||
fMl1.logWarningMessage(msg);
|
||||
break;
|
||||
case LOG_TYPE_ERROR:
|
||||
fMl1.logErrorMessage(msg);
|
||||
break;
|
||||
fMl1.logErrorMessage(msg);
|
||||
break;
|
||||
case LOG_TYPE_CRITICAL:
|
||||
fMl1.logCriticalMessage(msg);
|
||||
break;
|
||||
}
|
||||
fMl1.logCriticalMessage(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
return msg.msg();*/
|
||||
return msg.msg();*/
|
||||
}
|
||||
|
||||
const std::string Logger::logMessage(LOG_TYPE logLevel, const Message& msg, const LoggingID& logInfo)
|
||||
{
|
||||
mutex::scoped_lock lk(fLogLock);
|
||||
fMl1.logData(logInfo);
|
||||
mutex::scoped_lock lk(fLogLock);
|
||||
fMl1.logData(logInfo);
|
||||
|
||||
switch (logLevel)
|
||||
{
|
||||
case LOG_TYPE_DEBUG:
|
||||
default:
|
||||
fMl1.logDebugMessage(msg);
|
||||
break;
|
||||
case LOG_TYPE_INFO:
|
||||
fMl1.logInfoMessage(msg);
|
||||
break;
|
||||
case LOG_TYPE_WARNING:
|
||||
fMl1.logWarningMessage(msg);
|
||||
break;
|
||||
case LOG_TYPE_ERROR:
|
||||
fMl1.logErrorMessage(msg);
|
||||
break;
|
||||
case LOG_TYPE_CRITICAL:
|
||||
fMl1.logCriticalMessage(msg);
|
||||
break;
|
||||
}
|
||||
switch (logLevel)
|
||||
{
|
||||
case LOG_TYPE_DEBUG:
|
||||
default:
|
||||
fMl1.logDebugMessage(msg);
|
||||
break;
|
||||
|
||||
return msg.msg();
|
||||
case LOG_TYPE_INFO:
|
||||
fMl1.logInfoMessage(msg);
|
||||
break;
|
||||
|
||||
case LOG_TYPE_WARNING:
|
||||
fMl1.logWarningMessage(msg);
|
||||
break;
|
||||
|
||||
case LOG_TYPE_ERROR:
|
||||
fMl1.logErrorMessage(msg);
|
||||
break;
|
||||
|
||||
case LOG_TYPE_CRITICAL:
|
||||
fMl1.logCriticalMessage(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
return msg.msg();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,44 +42,50 @@ typedef std::map<Message::MessageID, Message> MsgMap;
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
/** @brief ctor
|
||||
*
|
||||
* @param subsys the subsystem id
|
||||
*/
|
||||
explicit Logger(unsigned subsys);
|
||||
/** @brief ctor
|
||||
*
|
||||
* @param subsys the subsystem id
|
||||
*/
|
||||
explicit Logger(unsigned subsys);
|
||||
|
||||
/** @brief log a message
|
||||
*
|
||||
* Log a message at a certain debug level
|
||||
*/
|
||||
const std::string logMessage(LOG_TYPE logLevel, Message::MessageID mid,
|
||||
const Message::Args& args, const LoggingID& logInfo);
|
||||
|
||||
/** @brief log a formated message
|
||||
*
|
||||
* For the error framework to use
|
||||
*/
|
||||
const std::string logMessage(LOG_TYPE logLevel, const Message& message, const LoggingID& logInfo);
|
||||
/** @brief log a message
|
||||
*
|
||||
* Log a message at a certain debug level
|
||||
*/
|
||||
const std::string logMessage(LOG_TYPE logLevel, Message::MessageID mid,
|
||||
const Message::Args& args, const LoggingID& logInfo);
|
||||
|
||||
/** @brief set the message map for this logger
|
||||
*
|
||||
* This method sets the message map for this logger. You need to call this (once and only once) before
|
||||
* using the class. The map needs to be constructed before and given to this class.
|
||||
*/
|
||||
void msgMap(const MsgMap& msgMap) { fMsgMap = msgMap; }
|
||||
/** @brief log a formated message
|
||||
*
|
||||
* For the error framework to use
|
||||
*/
|
||||
const std::string logMessage(LOG_TYPE logLevel, const Message& message, const LoggingID& logInfo);
|
||||
|
||||
/** @brief get the message map from this logger
|
||||
*/
|
||||
const MsgMap& msgMap() const { return fMsgMap; }
|
||||
/** @brief set the message map for this logger
|
||||
*
|
||||
* This method sets the message map for this logger. You need to call this (once and only once) before
|
||||
* using the class. The map needs to be constructed before and given to this class.
|
||||
*/
|
||||
void msgMap(const MsgMap& msgMap)
|
||||
{
|
||||
fMsgMap = msgMap;
|
||||
}
|
||||
|
||||
/** @brief get the message map from this logger
|
||||
*/
|
||||
const MsgMap& msgMap() const
|
||||
{
|
||||
return fMsgMap;
|
||||
}
|
||||
|
||||
private:
|
||||
// not copyable (because of the mutex)
|
||||
Logger(const Logger& rhs);
|
||||
Logger& operator=(const Logger& rhs);
|
||||
// not copyable (because of the mutex)
|
||||
Logger(const Logger& rhs);
|
||||
Logger& operator=(const Logger& rhs);
|
||||
|
||||
MsgMap fMsgMap;
|
||||
MessageLog fMl1;
|
||||
boost::mutex fLogLock;
|
||||
MsgMap fMsgMap;
|
||||
MessageLog fMl1;
|
||||
boost::mutex fLogLock;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<Logger> SPL;
|
||||
|
@ -27,24 +27,25 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace logging {
|
||||
namespace logging
|
||||
{
|
||||
|
||||
/** @brief a logging context structure
|
||||
*
|
||||
*/
|
||||
struct LoggingID
|
||||
{
|
||||
/** @brief LoggingID ctor
|
||||
*
|
||||
*/
|
||||
explicit LoggingID(unsigned subsysID=0, unsigned sessionID=0, unsigned txnID=0, unsigned ThdID=0)
|
||||
: fSubsysID(subsysID), fSessionID(sessionID), fTxnID(txnID), fThdID(ThdID)
|
||||
{}
|
||||
/** @brief LoggingID ctor
|
||||
*
|
||||
*/
|
||||
explicit LoggingID(unsigned subsysID = 0, unsigned sessionID = 0, unsigned txnID = 0, unsigned ThdID = 0)
|
||||
: fSubsysID(subsysID), fSessionID(sessionID), fTxnID(txnID), fThdID(ThdID)
|
||||
{}
|
||||
|
||||
unsigned fSubsysID; /// subsystem ID
|
||||
unsigned fSessionID; /// session ID
|
||||
unsigned fTxnID; /// transaction ID
|
||||
unsigned fThdID; /// thread ID
|
||||
unsigned fSubsysID; /// subsystem ID
|
||||
unsigned fSessionID; /// session ID
|
||||
unsigned fTxnID; /// transaction ID
|
||||
unsigned fThdID; /// thread ID
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,8 @@ using namespace config;
|
||||
|
||||
#include "installdir.h"
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
mutex mx;
|
||||
bool catalogLoaded = false;
|
||||
@ -51,165 +52,181 @@ CatMap catmap;
|
||||
|
||||
void loadCatalog()
|
||||
{
|
||||
Config* cf = Config::makeConfig();
|
||||
string configFile(cf->getConfig("MessageLog", "MessageLogFile"));
|
||||
if (configFile.length() == 0)
|
||||
configFile = startup::StartUp::installDir() + "/etc/MessageFile.txt";
|
||||
ifstream msgFile(configFile.c_str());
|
||||
while (msgFile.good())
|
||||
{
|
||||
stringbuf* sb = new stringbuf;
|
||||
msgFile.get(*sb);
|
||||
string m = sb->str();
|
||||
delete sb;
|
||||
if (m.length() > 0 && m[0] != '#')
|
||||
{
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep("\t");
|
||||
tokenizer tokens(m, sep);
|
||||
tokenizer::iterator tok_iter = tokens.begin();
|
||||
if (tok_iter != tokens.end())
|
||||
{
|
||||
int msgid = atoi(tok_iter->c_str());
|
||||
++tok_iter;
|
||||
if (tok_iter != tokens.end())
|
||||
{
|
||||
string msgtext = *tok_iter;
|
||||
catmap[msgid] = msgtext;
|
||||
}
|
||||
}
|
||||
}
|
||||
ios_base::iostate st = msgFile.rdstate();
|
||||
if ((st & ios_base::failbit) && !(st & ios_base::eofbit))
|
||||
msgFile.clear();
|
||||
(void)msgFile.get();
|
||||
}
|
||||
Config* cf = Config::makeConfig();
|
||||
string configFile(cf->getConfig("MessageLog", "MessageLogFile"));
|
||||
|
||||
if (configFile.length() == 0)
|
||||
configFile = startup::StartUp::installDir() + "/etc/MessageFile.txt";
|
||||
|
||||
ifstream msgFile(configFile.c_str());
|
||||
|
||||
while (msgFile.good())
|
||||
{
|
||||
stringbuf* sb = new stringbuf;
|
||||
msgFile.get(*sb);
|
||||
string m = sb->str();
|
||||
delete sb;
|
||||
|
||||
if (m.length() > 0 && m[0] != '#')
|
||||
{
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep("\t");
|
||||
tokenizer tokens(m, sep);
|
||||
tokenizer::iterator tok_iter = tokens.begin();
|
||||
|
||||
if (tok_iter != tokens.end())
|
||||
{
|
||||
int msgid = atoi(tok_iter->c_str());
|
||||
++tok_iter;
|
||||
|
||||
if (tok_iter != tokens.end())
|
||||
{
|
||||
string msgtext = *tok_iter;
|
||||
catmap[msgid] = msgtext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ios_base::iostate st = msgFile.rdstate();
|
||||
|
||||
if ((st & ios_base::failbit) && !(st & ios_base::eofbit))
|
||||
msgFile.clear();
|
||||
|
||||
(void)msgFile.get();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace logging {
|
||||
namespace logging
|
||||
{
|
||||
|
||||
Message::Message(const MessageID msgid) :
|
||||
fMsgID(msgid), fMsg(lookupMessage(msgid)), fConfig(Config::makeConfig())
|
||||
fMsgID(msgid), fMsg(lookupMessage(msgid)), fConfig(Config::makeConfig())
|
||||
{
|
||||
}
|
||||
|
||||
Message::Message(const string msg):
|
||||
fMsgID(0), fMsg(msg), fConfig(Config::makeConfig())
|
||||
fMsgID(0), fMsg(msg), fConfig(Config::makeConfig())
|
||||
{
|
||||
}
|
||||
|
||||
void Message::swap(Message& rhs)
|
||||
{
|
||||
std::swap(fMsgID, rhs.fMsgID);
|
||||
std::swap(fMsg, rhs.fMsg);
|
||||
std::swap(fConfig, rhs.fConfig);
|
||||
std::swap(fMsgID, rhs.fMsgID);
|
||||
std::swap(fMsg, rhs.fMsg);
|
||||
std::swap(fConfig, rhs.fConfig);
|
||||
}
|
||||
|
||||
void Message::Args::add(int i)
|
||||
{
|
||||
fArgs.push_back(long(i));
|
||||
fArgs.push_back(long(i));
|
||||
}
|
||||
|
||||
void Message::Args::add(uint64_t u64)
|
||||
{
|
||||
fArgs.push_back(u64);
|
||||
fArgs.push_back(u64);
|
||||
}
|
||||
|
||||
void Message::Args::add(const string& s)
|
||||
{
|
||||
fArgs.push_back(s);
|
||||
fArgs.push_back(s);
|
||||
}
|
||||
|
||||
void Message::Args::add(double d)
|
||||
{
|
||||
fArgs.push_back(d);
|
||||
fArgs.push_back(d);
|
||||
}
|
||||
|
||||
void Message::Args::reset()
|
||||
{
|
||||
fArgs.clear();
|
||||
fArgs.clear();
|
||||
}
|
||||
|
||||
void Message::format(const Args& args)
|
||||
{
|
||||
Args::AnyVec::const_iterator iter = args.args().begin();
|
||||
Args::AnyVec::const_iterator end = args.args().end();
|
||||
Args::AnyVec::const_iterator iter = args.args().begin();
|
||||
Args::AnyVec::const_iterator end = args.args().end();
|
||||
|
||||
boost::format fmt(fMsg);
|
||||
fmt.exceptions(boost::io::no_error_bits);
|
||||
boost::format fmt(fMsg);
|
||||
fmt.exceptions(boost::io::no_error_bits);
|
||||
|
||||
while (iter != end)
|
||||
{
|
||||
if (iter->type() == typeid(long))
|
||||
{
|
||||
long l = any_cast<long>(*iter);
|
||||
fmt % l;
|
||||
}
|
||||
else if (iter->type() == typeid(uint64_t))
|
||||
{
|
||||
uint64_t u64 = any_cast<uint64_t>(*iter);
|
||||
fmt % u64;
|
||||
}
|
||||
else if (iter->type() == typeid(double))
|
||||
{
|
||||
double d = any_cast<double>(*iter);
|
||||
fmt % d;
|
||||
}
|
||||
else if (iter->type() == typeid(string))
|
||||
{
|
||||
string s = any_cast<string>(*iter);
|
||||
fmt % s;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw logic_error("Message::format: unexpected type in argslist");
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
while (iter != end)
|
||||
{
|
||||
if (iter->type() == typeid(long))
|
||||
{
|
||||
long l = any_cast<long>(*iter);
|
||||
fmt % l;
|
||||
}
|
||||
else if (iter->type() == typeid(uint64_t))
|
||||
{
|
||||
uint64_t u64 = any_cast<uint64_t>(*iter);
|
||||
fmt % u64;
|
||||
}
|
||||
else if (iter->type() == typeid(double))
|
||||
{
|
||||
double d = any_cast<double>(*iter);
|
||||
fmt % d;
|
||||
}
|
||||
else if (iter->type() == typeid(string))
|
||||
{
|
||||
string s = any_cast<string>(*iter);
|
||||
fmt % s;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw logic_error("Message::format: unexpected type in argslist");
|
||||
}
|
||||
|
||||
fMsg = fmt.str();
|
||||
++iter;
|
||||
}
|
||||
|
||||
fMsg = fmt.str();
|
||||
}
|
||||
|
||||
/* static */
|
||||
const string Message::lookupMessage(const MessageID& msgid)
|
||||
{
|
||||
if (!catalogLoaded)
|
||||
{
|
||||
mutex::scoped_lock lock(mx);
|
||||
if (!catalogLoaded)
|
||||
{
|
||||
loadCatalog();
|
||||
catalogLoaded = true;
|
||||
}
|
||||
}
|
||||
string msgstr;
|
||||
CatMap::const_iterator iter = catmap.find(msgid);
|
||||
if (iter == catmap.end())
|
||||
{
|
||||
iter = catmap.find(0);
|
||||
if (iter == catmap.end())
|
||||
{
|
||||
msgstr = "%1% %2% %3% %4% %5%";
|
||||
}
|
||||
else
|
||||
{
|
||||
msgstr = iter->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msgstr = iter->second;
|
||||
}
|
||||
ostringstream oss;
|
||||
oss << "CAL" << setw(4) << setfill('0') << msgid << ": " << msgstr;
|
||||
return oss.str();
|
||||
if (!catalogLoaded)
|
||||
{
|
||||
mutex::scoped_lock lock(mx);
|
||||
|
||||
if (!catalogLoaded)
|
||||
{
|
||||
loadCatalog();
|
||||
catalogLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
string msgstr;
|
||||
CatMap::const_iterator iter = catmap.find(msgid);
|
||||
|
||||
if (iter == catmap.end())
|
||||
{
|
||||
iter = catmap.find(0);
|
||||
|
||||
if (iter == catmap.end())
|
||||
{
|
||||
msgstr = "%1% %2% %3% %4% %5%";
|
||||
}
|
||||
else
|
||||
{
|
||||
msgstr = iter->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msgstr = iter->second;
|
||||
}
|
||||
|
||||
ostringstream oss;
|
||||
oss << "CAL" << setw(4) << setfill('0') << msgid << ": " << msgstr;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
void Message::reset()
|
||||
{
|
||||
fMsg = lookupMessage(fMsgID);
|
||||
fMsg = lookupMessage(fMsgID);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,80 +32,83 @@
|
||||
using namespace std;
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
namespace ba=boost::assign;
|
||||
namespace ba = boost::assign;
|
||||
|
||||
#include "messagelog.h"
|
||||
#include "loggingid.h"
|
||||
#include "messageobj.h"
|
||||
#include "messageids.h"
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
using namespace logging;
|
||||
|
||||
/*
|
||||
* This list matches SubsystemIDs.txt, but has names matching Process Config DB
|
||||
*/
|
||||
const vector<string> SubsystemID = ba::list_of
|
||||
("Calpont") // id = 0 default
|
||||
("ddljoblist") // id = 1
|
||||
("ddlpackage") // id = 2
|
||||
("dmlpackage") // id = 3
|
||||
("execplan") // id = 4
|
||||
("joblist") // id = 5
|
||||
("resultset") // id = 6
|
||||
("mcsadmin") // id = 7
|
||||
("oamcpp") // id = 8
|
||||
("ServerMonitor") // id = 9
|
||||
("traphandler") // id = 10
|
||||
("alarmmanager") // id = 11
|
||||
("configcpp") // id = 12
|
||||
("loggingcpp") // id = 13
|
||||
("messageqcpp") // id = 14
|
||||
("DDLProc") // id = 15
|
||||
("ExeMgr") // id = 16
|
||||
("ProcessManager") // id = 17
|
||||
("ProcessMonitor") // id = 18
|
||||
("writeengine") // id = 19
|
||||
("DMLProc") // id = 20
|
||||
("dmlpackageproc") // id = 21
|
||||
("threadpool") // id = 22
|
||||
("ddlpackageproc") // id = 23
|
||||
("dbcon") // id = 24
|
||||
("DiskManager") // id = 25
|
||||
("RouteMsg") // id = 26
|
||||
("SQLBuffMgr") // id = 27
|
||||
("PrimProc") // id = 28
|
||||
("controllernode") // id = 29
|
||||
("workernode") // id = 30
|
||||
("messagequeue") // id = 31
|
||||
("writeengineserver")//id = 32
|
||||
("writeenginesplit")// id = 33
|
||||
("cpimport.bin") // id = 34
|
||||
("IDBFile") // id = 35
|
||||
;
|
||||
("Calpont") // id = 0 default
|
||||
("ddljoblist") // id = 1
|
||||
("ddlpackage") // id = 2
|
||||
("dmlpackage") // id = 3
|
||||
("execplan") // id = 4
|
||||
("joblist") // id = 5
|
||||
("resultset") // id = 6
|
||||
("mcsadmin") // id = 7
|
||||
("oamcpp") // id = 8
|
||||
("ServerMonitor") // id = 9
|
||||
("traphandler") // id = 10
|
||||
("alarmmanager") // id = 11
|
||||
("configcpp") // id = 12
|
||||
("loggingcpp") // id = 13
|
||||
("messageqcpp") // id = 14
|
||||
("DDLProc") // id = 15
|
||||
("ExeMgr") // id = 16
|
||||
("ProcessManager") // id = 17
|
||||
("ProcessMonitor") // id = 18
|
||||
("writeengine") // id = 19
|
||||
("DMLProc") // id = 20
|
||||
("dmlpackageproc") // id = 21
|
||||
("threadpool") // id = 22
|
||||
("ddlpackageproc") // id = 23
|
||||
("dbcon") // id = 24
|
||||
("DiskManager") // id = 25
|
||||
("RouteMsg") // id = 26
|
||||
("SQLBuffMgr") // id = 27
|
||||
("PrimProc") // id = 28
|
||||
("controllernode") // id = 29
|
||||
("workernode") // id = 30
|
||||
("messagequeue") // id = 31
|
||||
("writeengineserver")//id = 32
|
||||
("writeenginesplit")// id = 33
|
||||
("cpimport.bin") // id = 34
|
||||
("IDBFile") // id = 35
|
||||
;
|
||||
|
||||
string timestr()
|
||||
{
|
||||
struct tm tm;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
struct tm tm;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
#ifdef _MSC_VER
|
||||
errno_t p = 0;
|
||||
time_t t = (time_t)tv.tv_sec;
|
||||
p = localtime_s(&tm, &t);
|
||||
if (p != 0)
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
errno_t p = 0;
|
||||
time_t t = (time_t)tv.tv_sec;
|
||||
p = localtime_s(&tm, &t);
|
||||
|
||||
if (p != 0)
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
|
||||
#else
|
||||
localtime_r(&tv.tv_sec, &tm);
|
||||
localtime_r(&tv.tv_sec, &tm);
|
||||
#endif
|
||||
|
||||
ostringstream oss;
|
||||
oss << setfill('0')
|
||||
<< setw(2) << tm.tm_sec
|
||||
<< '.'
|
||||
<< setw(6) << tv.tv_usec
|
||||
;
|
||||
return oss.str();
|
||||
ostringstream oss;
|
||||
oss << setfill('0')
|
||||
<< setw(2) << tm.tm_sec
|
||||
<< '.'
|
||||
<< setw(6) << tv.tv_usec
|
||||
;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
void closeLog()
|
||||
@ -114,156 +117,162 @@ void closeLog()
|
||||
|
||||
void openLog(unsigned subsystemid, int localLogNum)
|
||||
{
|
||||
if (subsystemid >= SubsystemID.size())
|
||||
subsystemid = 0;
|
||||
if (subsystemid >= SubsystemID.size())
|
||||
subsystemid = 0;
|
||||
}
|
||||
|
||||
const string escape_pct(const string& in)
|
||||
{
|
||||
string out(in);
|
||||
string::size_type pos;
|
||||
pos = out.find('%', 0);
|
||||
while (pos != string::npos)
|
||||
{
|
||||
out.replace(pos, 1, "%%");
|
||||
pos = out.find('%', pos+2);
|
||||
}
|
||||
return out;
|
||||
string out(in);
|
||||
string::size_type pos;
|
||||
pos = out.find('%', 0);
|
||||
|
||||
while (pos != string::npos)
|
||||
{
|
||||
out.replace(pos, 1, "%%");
|
||||
pos = out.find('%', pos + 2);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace logging {
|
||||
namespace logging
|
||||
{
|
||||
|
||||
MessageLog::MessageLog(const LoggingID& initData, int localLogNum) :
|
||||
fLogData(initData), fFacility(localLogNum)
|
||||
fLogData(initData), fFacility(localLogNum)
|
||||
{
|
||||
openLog(fLogData.fSubsysID, fFacility);
|
||||
openLog(fLogData.fSubsysID, fFacility);
|
||||
}
|
||||
|
||||
void MessageLog::logData(const LoggingID& logData)
|
||||
{
|
||||
if (fLogData.fSubsysID != logData.fSubsysID)
|
||||
{
|
||||
closeLog();
|
||||
openLog(logData.fSubsysID, fFacility);
|
||||
}
|
||||
fLogData = logData;
|
||||
if (fLogData.fSubsysID != logData.fSubsysID)
|
||||
{
|
||||
closeLog();
|
||||
openLog(logData.fSubsysID, fFacility);
|
||||
}
|
||||
|
||||
fLogData = logData;
|
||||
}
|
||||
|
||||
MessageLog::~MessageLog()
|
||||
{
|
||||
closeLog();
|
||||
closeLog();
|
||||
}
|
||||
|
||||
const string MessageLog::format(const Message& msg, const char prefix)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << timestr() << " |"
|
||||
<< fLogData.fSessionID
|
||||
<< '|' << fLogData.fTxnID
|
||||
<< '|' << fLogData.fThdID
|
||||
<< "| "
|
||||
<< prefix << ' ' << setw(2) << setfill('0') << fLogData.fSubsysID
|
||||
<< ' ' << msg.msg()
|
||||
;
|
||||
return escape_pct(oss.str());
|
||||
}
|
||||
ostringstream oss;
|
||||
oss << timestr() << " |"
|
||||
<< fLogData.fSessionID
|
||||
<< '|' << fLogData.fTxnID
|
||||
<< '|' << fLogData.fThdID
|
||||
<< "| "
|
||||
<< prefix << ' ' << setw(2) << setfill('0') << fLogData.fSubsysID
|
||||
<< ' ' << msg.msg()
|
||||
;
|
||||
return escape_pct(oss.str());
|
||||
}
|
||||
|
||||
void MessageLog::logDebugMessage(const Message& msg)
|
||||
{
|
||||
::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0|LOG_PID, fFacility);
|
||||
::syslog(LOG_DEBUG, format(msg, 'D').c_str());
|
||||
::closelog();
|
||||
::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0 | LOG_PID, fFacility);
|
||||
::syslog(LOG_DEBUG, format(msg, 'D').c_str());
|
||||
::closelog();
|
||||
}
|
||||
|
||||
void MessageLog::logInfoMessage(const Message& msg)
|
||||
{
|
||||
::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0|LOG_PID, fFacility);
|
||||
::syslog(LOG_INFO, format(msg, 'I').c_str());
|
||||
::closelog();
|
||||
::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0 | LOG_PID, fFacility);
|
||||
::syslog(LOG_INFO, format(msg, 'I').c_str());
|
||||
::closelog();
|
||||
}
|
||||
|
||||
void MessageLog::logWarningMessage(const Message& msg)
|
||||
{
|
||||
::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0|LOG_PID, fFacility);
|
||||
::syslog(LOG_WARNING, format(msg, 'W').c_str());
|
||||
::closelog();
|
||||
::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0 | LOG_PID, fFacility);
|
||||
::syslog(LOG_WARNING, format(msg, 'W').c_str());
|
||||
::closelog();
|
||||
}
|
||||
|
||||
void MessageLog::logErrorMessage(const Message& msg)
|
||||
{
|
||||
// @bug 24 use 'E' instead of 'S'
|
||||
::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0|LOG_PID, fFacility);
|
||||
::syslog(LOG_ERR, format(msg, 'E').c_str());
|
||||
::closelog();
|
||||
// @bug 24 use 'E' instead of 'S'
|
||||
::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0 | LOG_PID, fFacility);
|
||||
::syslog(LOG_ERR, format(msg, 'E').c_str());
|
||||
::closelog();
|
||||
}
|
||||
|
||||
void MessageLog::logCriticalMessage(const Message& msg)
|
||||
{
|
||||
::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0|LOG_PID, fFacility);
|
||||
::syslog(LOG_CRIT, format(msg, 'C').c_str());
|
||||
::closelog();
|
||||
::openlog(SubsystemID[fLogData.fSubsysID].c_str(), 0 | LOG_PID, fFacility);
|
||||
::syslog(LOG_CRIT, format(msg, 'C').c_str());
|
||||
::closelog();
|
||||
}
|
||||
//Bug 5218. comment out the following functions to alleviate issue where dml messages show up in crit.log. This
|
||||
// will turn off data_mods.log.
|
||||
void logDML(unsigned sessionId, unsigned txnId, const string& statement, const string& owner)
|
||||
{
|
||||
/* logging::Message::Args args;
|
||||
|
||||
unsigned subsystemId = 20; // DMLProc
|
||||
unsigned threadId = 0; // 0 for now
|
||||
|
||||
logging::LoggingID loggingId(subsystemId, sessionId, txnId, threadId);
|
||||
logging::MessageLog messageLog(loggingId, LOG_LOCAL2);
|
||||
logging::Message m(M0017);
|
||||
args.add("|" + owner + "|" + statement);
|
||||
m.format(args);
|
||||
messageLog.logCriticalMessage(m); */
|
||||
}
|
||||
|
||||
void logDDL(unsigned sessionId, unsigned txnId, const string& statement, const string& owner)
|
||||
// will turn off data_mods.log.
|
||||
void logDML(unsigned sessionId, unsigned txnId, const string& statement, const string& owner)
|
||||
{
|
||||
/*
|
||||
logging::Message::Args args;
|
||||
/* logging::Message::Args args;
|
||||
|
||||
unsigned subsystemId = 15; // DDLProc
|
||||
unsigned threadId = 0; // 0 for now
|
||||
unsigned subsystemId = 20; // DMLProc
|
||||
unsigned threadId = 0; // 0 for now
|
||||
|
||||
logging::LoggingID loggingId(subsystemId, sessionId, txnId, threadId);
|
||||
logging::MessageLog messageLog(loggingId, LOG_LOCAL2);
|
||||
logging::Message m(M0018);
|
||||
args.add("|" + owner + "|" + statement);
|
||||
m.format(args);
|
||||
messageLog.logCriticalMessage(m); */
|
||||
logging::LoggingID loggingId(subsystemId, sessionId, txnId, threadId);
|
||||
logging::MessageLog messageLog(loggingId, LOG_LOCAL2);
|
||||
logging::Message m(M0017);
|
||||
args.add("|" + owner + "|" + statement);
|
||||
m.format(args);
|
||||
messageLog.logCriticalMessage(m); */
|
||||
}
|
||||
|
||||
void logCommand(unsigned sessionId, unsigned txnId, const string& statement) {
|
||||
/* logging::Message::Args args;
|
||||
void logDDL(unsigned sessionId, unsigned txnId, const string& statement, const string& owner)
|
||||
{
|
||||
/*
|
||||
logging::Message::Args args;
|
||||
|
||||
unsigned subsystemId = 20; // DMLProc
|
||||
unsigned threadId = 0; // 0 for now
|
||||
unsigned subsystemId = 15; // DDLProc
|
||||
unsigned threadId = 0; // 0 for now
|
||||
|
||||
logging::LoggingID loggingId(subsystemId, sessionId, txnId, threadId);
|
||||
logging::MessageLog messageLog(loggingId, LOG_LOCAL2);
|
||||
logging::Message m(M0019);
|
||||
args.add("|" + statement);
|
||||
m.format(args);
|
||||
messageLog.logCriticalMessage(m); */
|
||||
logging::LoggingID loggingId(subsystemId, sessionId, txnId, threadId);
|
||||
logging::MessageLog messageLog(loggingId, LOG_LOCAL2);
|
||||
logging::Message m(M0018);
|
||||
args.add("|" + owner + "|" + statement);
|
||||
m.format(args);
|
||||
messageLog.logCriticalMessage(m); */
|
||||
}
|
||||
|
||||
void logEventToDataLog(unsigned messageId, const string& messageText) {
|
||||
/* logging::Message::Args args;
|
||||
void logCommand(unsigned sessionId, unsigned txnId, const string& statement)
|
||||
{
|
||||
/* logging::Message::Args args;
|
||||
|
||||
unsigned subsystemId = 20; // DMLProc
|
||||
unsigned threadId = 0; // 0 for now
|
||||
unsigned subsystemId = 20; // DMLProc
|
||||
unsigned threadId = 0; // 0 for now
|
||||
|
||||
logging::LoggingID loggingId(subsystemId, 0, 0, threadId);
|
||||
logging::MessageLog messageLog(loggingId, LOG_LOCAL2);
|
||||
logging::Message m(messageId);
|
||||
args.add(messageText);
|
||||
m.format(args);
|
||||
messageLog.logCriticalMessage(m); */
|
||||
logging::LoggingID loggingId(subsystemId, sessionId, txnId, threadId);
|
||||
logging::MessageLog messageLog(loggingId, LOG_LOCAL2);
|
||||
logging::Message m(M0019);
|
||||
args.add("|" + statement);
|
||||
m.format(args);
|
||||
messageLog.logCriticalMessage(m); */
|
||||
}
|
||||
|
||||
void logEventToDataLog(unsigned messageId, const string& messageText)
|
||||
{
|
||||
/* logging::Message::Args args;
|
||||
|
||||
unsigned subsystemId = 20; // DMLProc
|
||||
unsigned threadId = 0; // 0 for now
|
||||
|
||||
logging::LoggingID loggingId(subsystemId, 0, 0, threadId);
|
||||
logging::MessageLog messageLog(loggingId, LOG_LOCAL2);
|
||||
logging::Message m(messageId);
|
||||
args.add(messageText);
|
||||
m.format(args);
|
||||
messageLog.logCriticalMessage(m); */
|
||||
}
|
||||
|
||||
} //namespace logging
|
||||
|
@ -31,18 +31,19 @@
|
||||
|
||||
class MessageLoggingTest;
|
||||
|
||||
namespace logging {
|
||||
namespace logging
|
||||
{
|
||||
|
||||
/** @brief Log Types
|
||||
*/
|
||||
enum LOG_TYPE
|
||||
{
|
||||
LOG_TYPE_DEBUG, // 0 = debug
|
||||
LOG_TYPE_INFO, // 1 = info
|
||||
LOG_TYPE_WARNING, // 2 = warning
|
||||
LOG_TYPE_ERROR, // 3 = error
|
||||
LOG_TYPE_CRITICAL // 4 = critical
|
||||
};
|
||||
/** @brief Log Types
|
||||
*/
|
||||
enum LOG_TYPE
|
||||
{
|
||||
LOG_TYPE_DEBUG, // 0 = debug
|
||||
LOG_TYPE_INFO, // 1 = info
|
||||
LOG_TYPE_WARNING, // 2 = warning
|
||||
LOG_TYPE_ERROR, // 3 = error
|
||||
LOG_TYPE_CRITICAL // 4 = critical
|
||||
};
|
||||
|
||||
|
||||
class Message;
|
||||
@ -53,80 +54,86 @@ class Message;
|
||||
class MessageLog
|
||||
{
|
||||
public:
|
||||
/** @brief ctor
|
||||
* @param initData the LogginID object.
|
||||
* @param facility openLog will be called using this as the third parm.
|
||||
*/
|
||||
MessageLog(const LoggingID& initData, int facility=LOG_LOCAL1);
|
||||
/** @brief ctor
|
||||
* @param initData the LogginID object.
|
||||
* @param facility openLog will be called using this as the third parm.
|
||||
*/
|
||||
MessageLog(const LoggingID& initData, int facility = LOG_LOCAL1);
|
||||
|
||||
/** @brief dtor
|
||||
*
|
||||
*/
|
||||
~MessageLog();
|
||||
/** @brief dtor
|
||||
*
|
||||
*/
|
||||
~MessageLog();
|
||||
|
||||
/** @brief log a debug message
|
||||
*
|
||||
* @param msg the message to log
|
||||
*/
|
||||
void logDebugMessage(const Message& msg);
|
||||
/** @brief log a debug message
|
||||
*
|
||||
* @param msg the message to log
|
||||
*/
|
||||
void logDebugMessage(const Message& msg);
|
||||
|
||||
/** @brief log an info message
|
||||
*
|
||||
* @param msg the message to log
|
||||
*/
|
||||
void logInfoMessage(const Message& msg);
|
||||
/** @brief log an info message
|
||||
*
|
||||
* @param msg the message to log
|
||||
*/
|
||||
void logInfoMessage(const Message& msg);
|
||||
|
||||
/** @brief log a warning message
|
||||
*
|
||||
* @param msg the message to log
|
||||
*/
|
||||
void logWarningMessage(const Message& msg);
|
||||
/** @brief log a warning message
|
||||
*
|
||||
* @param msg the message to log
|
||||
*/
|
||||
void logWarningMessage(const Message& msg);
|
||||
|
||||
/** @brief log an error message
|
||||
*
|
||||
* @param msg the message to log
|
||||
*/
|
||||
void logErrorMessage(const Message& msg);
|
||||
/** @brief log an error message
|
||||
*
|
||||
* @param msg the message to log
|
||||
*/
|
||||
void logErrorMessage(const Message& msg);
|
||||
|
||||
/** @brief log a serious message
|
||||
*
|
||||
* @param msg the message to log
|
||||
* @note this is the same as calling logErrorMessage()
|
||||
* @bug 24 add logErrorMessage() and make logSeriousMessage() call it
|
||||
*/
|
||||
void logSeriousMessage(const Message& msg) { logErrorMessage(msg); }
|
||||
/** @brief log a serious message
|
||||
*
|
||||
* @param msg the message to log
|
||||
* @note this is the same as calling logErrorMessage()
|
||||
* @bug 24 add logErrorMessage() and make logSeriousMessage() call it
|
||||
*/
|
||||
void logSeriousMessage(const Message& msg)
|
||||
{
|
||||
logErrorMessage(msg);
|
||||
}
|
||||
|
||||
/** @brief log a critial message
|
||||
*
|
||||
* @param msg the message to log
|
||||
*/
|
||||
void logCriticalMessage(const Message& msg);
|
||||
/** @brief log a critial message
|
||||
*
|
||||
* @param msg the message to log
|
||||
*/
|
||||
void logCriticalMessage(const Message& msg);
|
||||
|
||||
/** @brief LoggingID mutator
|
||||
*
|
||||
* @param logData the new LoggingID. If the subsystem id is changed, the syslog connection will be closed
|
||||
* and reopened.
|
||||
*/
|
||||
void logData(const LoggingID& logData);
|
||||
/** @brief LoggingID mutator
|
||||
*
|
||||
* @param logData the new LoggingID. If the subsystem id is changed, the syslog connection will be closed
|
||||
* and reopened.
|
||||
*/
|
||||
void logData(const LoggingID& logData);
|
||||
|
||||
/** @brief LoggingID accessor
|
||||
*
|
||||
*/
|
||||
const LoggingID& logData() const { return fLogData; }
|
||||
/** @brief LoggingID accessor
|
||||
*
|
||||
*/
|
||||
const LoggingID& logData() const
|
||||
{
|
||||
return fLogData;
|
||||
}
|
||||
|
||||
friend class ::MessageLoggingTest;
|
||||
friend class ::MessageLoggingTest;
|
||||
|
||||
protected:
|
||||
|
||||
const std::string format(const Message& msg, const char prefix='U');
|
||||
const std::string format(const Message& msg, const char prefix = 'U');
|
||||
|
||||
private:
|
||||
//defaults okay
|
||||
//MessageLog(const MessageLog& rhs);
|
||||
//MessageLog& operator=(const MessageLog& rhs);
|
||||
//defaults okay
|
||||
//MessageLog(const MessageLog& rhs);
|
||||
//MessageLog& operator=(const MessageLog& rhs);
|
||||
|
||||
LoggingID fLogData; /// the logging context data
|
||||
int fFacility; /// the syslog facility number
|
||||
LoggingID fLogData; /// the logging context data
|
||||
int fFacility; /// the syslog facility number
|
||||
};
|
||||
|
||||
/** @brief logs the DML statement using a Syslog critical message to LOG_LOCAL2.
|
||||
|
@ -38,7 +38,8 @@ class Config;
|
||||
|
||||
class MessageLoggingTest;
|
||||
|
||||
namespace logging {
|
||||
namespace logging
|
||||
{
|
||||
|
||||
/** @brief a message class
|
||||
*
|
||||
@ -47,112 +48,121 @@ namespace logging {
|
||||
class Message
|
||||
{
|
||||
public:
|
||||
/** @brief the args to a formatted message
|
||||
*/
|
||||
class Args
|
||||
{
|
||||
public:
|
||||
/** @brief the args vector
|
||||
*/
|
||||
typedef std::vector<boost::any> AnyVec;
|
||||
/** @brief the args to a formatted message
|
||||
*/
|
||||
class Args
|
||||
{
|
||||
public:
|
||||
/** @brief the args vector
|
||||
*/
|
||||
typedef std::vector<boost::any> AnyVec;
|
||||
|
||||
// default ctors & dtors okay
|
||||
// default ctors & dtors okay
|
||||
|
||||
/** @brief add an int arg to the message
|
||||
*/
|
||||
void add(int i);
|
||||
/** @brief add an int arg to the message
|
||||
*/
|
||||
void add(int i);
|
||||
|
||||
/** @brief add an unsigned 64 bit int arg to the message
|
||||
*/
|
||||
void add(uint64_t i);
|
||||
/** @brief add an unsigned 64 bit int arg to the message
|
||||
*/
|
||||
void add(uint64_t i);
|
||||
|
||||
/** @brief add a float arg to the message
|
||||
*/
|
||||
void add(double d);
|
||||
/** @brief add a float arg to the message
|
||||
*/
|
||||
void add(double d);
|
||||
|
||||
/** @brief add a string arg to the message
|
||||
*/
|
||||
void add(const std::string& s);
|
||||
/** @brief add a string arg to the message
|
||||
*/
|
||||
void add(const std::string& s);
|
||||
|
||||
/** @brief args accessor
|
||||
*/
|
||||
const AnyVec& args() const { return fArgs; }
|
||||
/** @brief args accessor
|
||||
*/
|
||||
const AnyVec& args() const
|
||||
{
|
||||
return fArgs;
|
||||
}
|
||||
|
||||
/** @brief reset the args list
|
||||
*
|
||||
*/
|
||||
void reset();
|
||||
/** @brief reset the args list
|
||||
*
|
||||
*/
|
||||
void reset();
|
||||
|
||||
friend class ::MessageLoggingTest;
|
||||
friend class ::MessageLoggingTest;
|
||||
|
||||
private:
|
||||
AnyVec fArgs; /// the args vector
|
||||
};
|
||||
private:
|
||||
AnyVec fArgs; /// the args vector
|
||||
};
|
||||
|
||||
/** @brief the MessageID type
|
||||
*/
|
||||
typedef unsigned MessageID;
|
||||
/** @brief the MessageID type
|
||||
*/
|
||||
typedef unsigned MessageID;
|
||||
|
||||
/** @brief default ctor
|
||||
*/
|
||||
explicit Message(const MessageID msgid=0);
|
||||
|
||||
/** @brief ctor turn a message string to a Message
|
||||
*
|
||||
* For error handling framework use to log error
|
||||
*/
|
||||
Message(const std::string msg);
|
||||
/** @brief default ctor
|
||||
*/
|
||||
explicit Message(const MessageID msgid = 0);
|
||||
|
||||
/** @brief format message with args
|
||||
*/
|
||||
void format(const Args& args);
|
||||
/** @brief ctor turn a message string to a Message
|
||||
*
|
||||
* For error handling framework use to log error
|
||||
*/
|
||||
Message(const std::string msg);
|
||||
|
||||
/** @brief msg accessor
|
||||
*/
|
||||
const std::string& msg() const { return fMsg; }
|
||||
/** @brief format message with args
|
||||
*/
|
||||
void format(const Args& args);
|
||||
|
||||
/** @brief swap
|
||||
*/
|
||||
void swap(Message& rhs);
|
||||
/** @brief msg accessor
|
||||
*/
|
||||
const std::string& msg() const
|
||||
{
|
||||
return fMsg;
|
||||
}
|
||||
|
||||
/** @brief lookup the message format string
|
||||
*
|
||||
* looks up the message format string for msgid. Returns a reasonable
|
||||
* default if one can't be found.
|
||||
*/
|
||||
static const std::string lookupMessage(const MessageID& msgid);
|
||||
/** @brief swap
|
||||
*/
|
||||
void swap(Message& rhs);
|
||||
|
||||
/** @brief reset the formated string
|
||||
*
|
||||
* The original, unformated string is restored, and this Message
|
||||
* is then ready for a new call to format().
|
||||
*/
|
||||
void reset();
|
||||
/** @brief lookup the message format string
|
||||
*
|
||||
* looks up the message format string for msgid. Returns a reasonable
|
||||
* default if one can't be found.
|
||||
*/
|
||||
static const std::string lookupMessage(const MessageID& msgid);
|
||||
|
||||
/** @brief msgID accessor
|
||||
*/
|
||||
const MessageID& msgID() const { return fMsgID; }
|
||||
/** @brief reset the formated string
|
||||
*
|
||||
* The original, unformated string is restored, and this Message
|
||||
* is then ready for a new call to format().
|
||||
*/
|
||||
void reset();
|
||||
|
||||
friend class ::MessageLoggingTest;
|
||||
/** @brief msgID accessor
|
||||
*/
|
||||
const MessageID& msgID() const
|
||||
{
|
||||
return fMsgID;
|
||||
}
|
||||
|
||||
friend class ::MessageLoggingTest;
|
||||
|
||||
private:
|
||||
//defaults okay
|
||||
//Message(const Message& rhs);
|
||||
//Message& operator=(const Message& rhs);
|
||||
//defaults okay
|
||||
//Message(const Message& rhs);
|
||||
//Message& operator=(const Message& rhs);
|
||||
|
||||
MessageID fMsgID; /// the msgID
|
||||
std::string fMsg; /// the formated or unformated message
|
||||
config::Config* fConfig; /// config file ptr
|
||||
MessageID fMsgID; /// the msgID
|
||||
std::string fMsg; /// the formated or unformated message
|
||||
config::Config* fConfig; /// config file ptr
|
||||
};
|
||||
|
||||
}//namespace logging
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<> inline void swap<logging::Message>(logging::Message& lhs, logging::Message&rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
template<> inline void swap<logging::Message>(logging::Message& lhs, logging::Message& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
}//namespace std
|
||||
|
||||
#endif
|
||||
|
@ -38,38 +38,40 @@ const unsigned LogEndSql = M0042;
|
||||
|
||||
//We can't use a member Logger here. When used with DML and DDL, the syslog gets closed by calls to DMLLog and DDLLog.
|
||||
SQLLogger::SQLLogger(const std::string sql, unsigned subsys, unsigned session, unsigned txn, unsigned thread)
|
||||
: fLogId(subsys, session, txn, thread), fLog(!sql.empty())
|
||||
: fLogId(subsys, session, txn, thread), fLog(!sql.empty())
|
||||
{
|
||||
makeMsgMap();
|
||||
if (fLog) logMessage(LOG_TYPE_DEBUG, sql, LogStartSql);
|
||||
makeMsgMap();
|
||||
|
||||
if (fLog) logMessage(LOG_TYPE_DEBUG, sql, LogStartSql);
|
||||
}
|
||||
|
||||
SQLLogger::SQLLogger(const std::string sql, const LoggingID& logId)
|
||||
: fLogId(logId.fSubsysID, logId.fSessionID, logId.fTxnID, logId.fThdID), fLog(!sql.empty())
|
||||
: fLogId(logId.fSubsysID, logId.fSessionID, logId.fTxnID, logId.fThdID), fLog(!sql.empty())
|
||||
{
|
||||
makeMsgMap();
|
||||
if (fLog) logMessage(LOG_TYPE_DEBUG, sql, LogStartSql);
|
||||
makeMsgMap();
|
||||
|
||||
if (fLog) logMessage(LOG_TYPE_DEBUG, sql, LogStartSql);
|
||||
}
|
||||
|
||||
void SQLLogger::makeMsgMap()
|
||||
{
|
||||
fMsgMap[LogDefaultMsg] = Message(LogDefaultMsg);
|
||||
fMsgMap[LogStartSql] = Message(LogStartSql);
|
||||
fMsgMap[LogEndSql] = Message(LogEndSql);
|
||||
fMsgMap[LogDefaultMsg] = Message(LogDefaultMsg);
|
||||
fMsgMap[LogStartSql] = Message(LogStartSql);
|
||||
fMsgMap[LogEndSql] = Message(LogEndSql);
|
||||
}
|
||||
|
||||
SQLLogger::~SQLLogger()
|
||||
{
|
||||
if (fLog) logMessage(LOG_TYPE_DEBUG, "", LogEndSql);
|
||||
{
|
||||
if (fLog) logMessage(LOG_TYPE_DEBUG, "", LogEndSql);
|
||||
}
|
||||
|
||||
std::string SQLLogger::logMessage(logging::LOG_TYPE logLevel, const std::string& msg, logging::Message::MessageID mid )
|
||||
{
|
||||
logging::Message::Args args;
|
||||
args.add(msg);
|
||||
Logger logger(fLogId.fSubsysID);
|
||||
logger.msgMap(fMsgMap);
|
||||
return logger.logMessage(logLevel, mid, args, fLogId);
|
||||
logging::Message::Args args;
|
||||
args.add(msg);
|
||||
Logger logger(fLogId.fSubsysID);
|
||||
logger.msgMap(fMsgMap);
|
||||
return logger.logMessage(logLevel, mid, args, fLogId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,18 +45,18 @@ extern const unsigned LogEndSql;
|
||||
class SQLLogger
|
||||
{
|
||||
public:
|
||||
SQLLogger(const std::string sql, unsigned subsys, unsigned session, unsigned txn = 0, unsigned thread = 0);
|
||||
SQLLogger(const std::string sql, const LoggingID& logId);
|
||||
SQLLogger(const std::string sql, unsigned subsys, unsigned session, unsigned txn = 0, unsigned thread = 0);
|
||||
SQLLogger(const std::string sql, const LoggingID& logId);
|
||||
|
||||
~SQLLogger();
|
||||
~SQLLogger();
|
||||
|
||||
std::string logMessage(logging::LOG_TYPE logLevel, const std::string& msg, logging::Message::MessageID mid = LogDefaultMsg );
|
||||
std::string logMessage(logging::LOG_TYPE logLevel, const std::string& msg, logging::Message::MessageID mid = LogDefaultMsg );
|
||||
|
||||
private:
|
||||
void makeMsgMap();
|
||||
MsgMap fMsgMap;
|
||||
LoggingID fLogId;
|
||||
bool fLog;
|
||||
void makeMsgMap();
|
||||
MsgMap fMsgMap;
|
||||
LoggingID fLogId;
|
||||
bool fLog;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -27,19 +27,19 @@
|
||||
// the first time start() is called until finish() is called. You should always match your
|
||||
// start and stop calls up.
|
||||
//
|
||||
// This works fine as long as you don't use it with huge numbers of calls. If you call start
|
||||
// This works fine as long as you don't use it with huge numbers of calls. If you call start
|
||||
// and stop too many times the overhead of the StopWatch class will start factoring in to your
|
||||
// results.
|
||||
//
|
||||
// How to use:
|
||||
//
|
||||
//
|
||||
// StopWatch timer;
|
||||
// timer.start("Loop only");
|
||||
// for(int i = 0; i < 6999075; i++)
|
||||
// {
|
||||
// }
|
||||
// timer.stop("Loop only");
|
||||
//
|
||||
//
|
||||
// timer.start("Loop Plus");
|
||||
// for(int i = 0; i < 100000; i++)
|
||||
// {
|
||||
@ -50,14 +50,14 @@
|
||||
// timer.finish();
|
||||
//
|
||||
// Produces this:
|
||||
//
|
||||
//
|
||||
// Seconds Percentage Calls Description
|
||||
// 0.02865 9.377% 1 Loop only
|
||||
// 0.27680 90.59% 1 Loop Plus
|
||||
// 0.12138 39.72% 100000 Inside loop
|
||||
//
|
||||
//
|
||||
// 0.30553 100 % 1 Total
|
||||
//
|
||||
//
|
||||
// Note that you can have overlapping timers which will make your percentages add up to more than 100%.
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@ -78,143 +78,169 @@ namespace logging
|
||||
|
||||
void StopWatch::stop(const string& message)
|
||||
{
|
||||
stop(message, 1);
|
||||
stop(message, 1);
|
||||
}
|
||||
|
||||
bool StopWatch::stop(const string& message, const int limit) {
|
||||
gettimeofday(&fTvLast, 0);
|
||||
fOpenCalls--;
|
||||
bool found = false;
|
||||
uint32_t idx = 0;
|
||||
for(uint32_t i = 0; i < fProcessStats.size(); i++) {
|
||||
if(fProcessStats[i].fProcess == message) {
|
||||
idx = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found) {
|
||||
//throw std::runtime_error("StopWatch::stop " + message + " called without calling start first.");
|
||||
std::cerr << "StopWatch receiving STOP for unknown event: " << message << std::endl;
|
||||
return false;
|
||||
}
|
||||
fProcessStats[idx].processStop();
|
||||
if(fProcessStats[idx].fStopCount >= limit)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool StopWatch::stop(const string& message, const int limit)
|
||||
{
|
||||
gettimeofday(&fTvLast, 0);
|
||||
fOpenCalls--;
|
||||
bool found = false;
|
||||
uint32_t idx = 0;
|
||||
|
||||
void StopWatch::start(const string& message) {
|
||||
fOpenCalls++;
|
||||
gettimeofday(&fTvLast, 0);
|
||||
bool found = false;
|
||||
uint32_t idx = 0;
|
||||
ProcessStats processStats;
|
||||
if(!fStarted) {
|
||||
fStarted = true;
|
||||
gettimeofday(&fTvStart, 0);
|
||||
}
|
||||
for(uint32_t i = 0; i < fProcessStats.size(); i++) {
|
||||
if(fProcessStats[i].fProcess == message) {
|
||||
idx = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found) {
|
||||
fProcessStats.push_back(processStats);
|
||||
idx = fProcessStats.size() - 1;
|
||||
}
|
||||
fProcessStats[idx].fProcess = message;
|
||||
fProcessStats[idx].processStart();
|
||||
}
|
||||
|
||||
void StopWatch::finish() {
|
||||
ostringstream oss;
|
||||
|
||||
oss << endl;
|
||||
oss << "Seconds Percentage Calls Description" << endl;
|
||||
|
||||
// total seconds elapsed
|
||||
double totalSeconds = 1.0;
|
||||
|
||||
// Add a last entry into the vector for total.
|
||||
ProcessStats total;
|
||||
total.fProcess = "Total";
|
||||
if (fProcessStats.size() > 0)
|
||||
{
|
||||
// Calculate the total seconds elapsed.
|
||||
totalSeconds =
|
||||
(fTvLast.tv_sec + (fTvLast.tv_usec / 1000000.0)) -
|
||||
(fTvStart.tv_sec + (fTvStart.tv_usec / 1000000.0));
|
||||
total.fTotalSeconds = totalSeconds;
|
||||
total.fStartCount = 1;
|
||||
for (uint32_t i = 0; i < fProcessStats.size(); i++)
|
||||
{
|
||||
if (fProcessStats[i].fProcess == message)
|
||||
{
|
||||
idx = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
total.fTotalSeconds = 0.0;
|
||||
total.fStartCount = 0;
|
||||
}
|
||||
fProcessStats.push_back(total);
|
||||
|
||||
for(uint32_t i = 0; i < fProcessStats.size(); i++) {
|
||||
if (!found)
|
||||
{
|
||||
//throw std::runtime_error("StopWatch::stop " + message + " called without calling start first.");
|
||||
std::cerr << "StopWatch receiving STOP for unknown event: " << message << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(i == (fProcessStats.size() - 1)) {
|
||||
oss << endl;
|
||||
}
|
||||
fProcessStats[idx].processStop();
|
||||
|
||||
// Seconds.
|
||||
string seconds;
|
||||
ostringstream ossTemp;
|
||||
ossTemp << fProcessStats[i].fTotalSeconds;
|
||||
seconds = ossTemp.str();
|
||||
seconds.resize(11, ' ');
|
||||
oss << seconds << " ";
|
||||
if (fProcessStats[idx].fStopCount >= limit)
|
||||
return true;
|
||||
|
||||
// Percentage.
|
||||
string percentage;
|
||||
ossTemp.str(""); // clear the stream.
|
||||
ossTemp << (fProcessStats[i].fTotalSeconds / totalSeconds) * 100.0;
|
||||
percentage = ossTemp.str();
|
||||
percentage.resize(11, ' ');
|
||||
oss << percentage << "% ";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Times Initiated.
|
||||
ossTemp.str(""); // clear the stream.
|
||||
ossTemp << fProcessStats[i].fStartCount;
|
||||
string timesInitiated = ossTemp.str();
|
||||
timesInitiated.resize(10, ' ');
|
||||
oss << timesInitiated << " ";
|
||||
|
||||
// Description.
|
||||
if(fId >= 0)
|
||||
oss << fId << ": " << fProcessStats[i].fProcess << endl;
|
||||
else
|
||||
oss << fProcessStats[i].fProcess << endl;
|
||||
}
|
||||
if(fOutputToFile) {
|
||||
void StopWatch::start(const string& message)
|
||||
{
|
||||
fOpenCalls++;
|
||||
gettimeofday(&fTvLast, 0);
|
||||
bool found = false;
|
||||
uint32_t idx = 0;
|
||||
ProcessStats processStats;
|
||||
|
||||
ofstream profLog;
|
||||
profLog.open(fLogFile.c_str(), std::ios::app);
|
||||
if (!fStarted)
|
||||
{
|
||||
fStarted = true;
|
||||
gettimeofday(&fTvStart, 0);
|
||||
}
|
||||
|
||||
// Output the date and time.
|
||||
time_t t = time(0);
|
||||
char timeString[50];
|
||||
ctime_r(&t, timeString);
|
||||
timeString[ strlen(timeString)-1 ] = '\0';
|
||||
profLog << endl << timeString;
|
||||
for (uint32_t i = 0; i < fProcessStats.size(); i++)
|
||||
{
|
||||
if (fProcessStats[i].fProcess == message)
|
||||
{
|
||||
idx = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Output the stopwatch info.
|
||||
profLog << oss.str();
|
||||
}
|
||||
else {
|
||||
cout << oss.str();
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
fProcessStats.push_back(processStats);
|
||||
idx = fProcessStats.size() - 1;
|
||||
}
|
||||
|
||||
fProcessStats[idx].fProcess = message;
|
||||
fProcessStats[idx].processStart();
|
||||
}
|
||||
|
||||
void StopWatch::finish()
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << endl;
|
||||
oss << "Seconds Percentage Calls Description" << endl;
|
||||
|
||||
// total seconds elapsed
|
||||
double totalSeconds = 1.0;
|
||||
|
||||
// Add a last entry into the vector for total.
|
||||
ProcessStats total;
|
||||
total.fProcess = "Total";
|
||||
|
||||
if (fProcessStats.size() > 0)
|
||||
{
|
||||
// Calculate the total seconds elapsed.
|
||||
totalSeconds =
|
||||
(fTvLast.tv_sec + (fTvLast.tv_usec / 1000000.0)) -
|
||||
(fTvStart.tv_sec + (fTvStart.tv_usec / 1000000.0));
|
||||
total.fTotalSeconds = totalSeconds;
|
||||
total.fStartCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
total.fTotalSeconds = 0.0;
|
||||
total.fStartCount = 0;
|
||||
}
|
||||
|
||||
fProcessStats.push_back(total);
|
||||
|
||||
for (uint32_t i = 0; i < fProcessStats.size(); i++)
|
||||
{
|
||||
|
||||
if (i == (fProcessStats.size() - 1))
|
||||
{
|
||||
oss << endl;
|
||||
}
|
||||
|
||||
// Seconds.
|
||||
string seconds;
|
||||
ostringstream ossTemp;
|
||||
ossTemp << fProcessStats[i].fTotalSeconds;
|
||||
seconds = ossTemp.str();
|
||||
seconds.resize(11, ' ');
|
||||
oss << seconds << " ";
|
||||
|
||||
// Percentage.
|
||||
string percentage;
|
||||
ossTemp.str(""); // clear the stream.
|
||||
ossTemp << (fProcessStats[i].fTotalSeconds / totalSeconds) * 100.0;
|
||||
percentage = ossTemp.str();
|
||||
percentage.resize(11, ' ');
|
||||
oss << percentage << "% ";
|
||||
|
||||
// Times Initiated.
|
||||
ossTemp.str(""); // clear the stream.
|
||||
ossTemp << fProcessStats[i].fStartCount;
|
||||
string timesInitiated = ossTemp.str();
|
||||
timesInitiated.resize(10, ' ');
|
||||
oss << timesInitiated << " ";
|
||||
|
||||
// Description.
|
||||
if (fId >= 0)
|
||||
oss << fId << ": " << fProcessStats[i].fProcess << endl;
|
||||
else
|
||||
oss << fProcessStats[i].fProcess << endl;
|
||||
}
|
||||
|
||||
if (fOutputToFile)
|
||||
{
|
||||
|
||||
ofstream profLog;
|
||||
profLog.open(fLogFile.c_str(), std::ios::app);
|
||||
|
||||
// Output the date and time.
|
||||
time_t t = time(0);
|
||||
char timeString[50];
|
||||
ctime_r(&t, timeString);
|
||||
timeString[ strlen(timeString) - 1 ] = '\0';
|
||||
profLog << endl << timeString;
|
||||
|
||||
// Output the stopwatch info.
|
||||
profLog << oss.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << oss.str();
|
||||
}
|
||||
|
||||
// Clear everything out.
|
||||
fStarted = false;
|
||||
fProcessStats.clear();
|
||||
|
||||
// Clear everything out.
|
||||
fStarted = false;
|
||||
fProcessStats.clear();
|
||||
|
||||
}
|
||||
|
||||
} // end of logging namespace
|
||||
|
@ -27,19 +27,19 @@
|
||||
// the first time start() is called until finish() is called. You should always match your
|
||||
// start and stop calls up.
|
||||
//
|
||||
// This works fine as long as you don't use it with huge numbers of calls. If you call start
|
||||
// This works fine as long as you don't use it with huge numbers of calls. If you call start
|
||||
// and stop too many times the overhead of the StopWatch class will start factoring in to your
|
||||
// results.
|
||||
//
|
||||
// How to use:
|
||||
//
|
||||
//
|
||||
// StopWatch timer;
|
||||
// timer.start("Loop only");
|
||||
// for(int i = 0; i < 6999075; i++)
|
||||
// {
|
||||
// }
|
||||
// timer.stop("Loop only");
|
||||
//
|
||||
//
|
||||
// timer.start("Loop Plus");
|
||||
// for(int i = 0; i < 100000; i++)
|
||||
// {
|
||||
@ -50,14 +50,14 @@
|
||||
// timer.finish();
|
||||
//
|
||||
// Produces this:
|
||||
//
|
||||
//
|
||||
// Seconds Percentage Calls Description
|
||||
// 0.02865 9.377% 1 Loop only
|
||||
// 0.27680 90.59% 1 Loop Plus
|
||||
// 0.12138 39.72% 100000 Inside loop
|
||||
//
|
||||
//
|
||||
// 0.30553 100 % 1 Total
|
||||
//
|
||||
//
|
||||
// Note that you can have overlapping timers which will make your percentages add up to more than 100%.
|
||||
#ifndef LOGGING_STOPWATCH_H
|
||||
#define LOGGING_STOPWATCH_H
|
||||
@ -75,61 +75,65 @@
|
||||
namespace logging
|
||||
{
|
||||
|
||||
class StopWatch {
|
||||
public:
|
||||
void start(const std::string& message);
|
||||
bool stop(const std::string& message, const int limit);
|
||||
void stop(const std::string& message);
|
||||
void finish();
|
||||
|
||||
bool isActive()
|
||||
{
|
||||
return fOpenCalls > 0;
|
||||
}
|
||||
StopWatch() : fStarted(false), fId(-1), fOpenCalls(0), fOutputToFile(false), fLogFile("") {};
|
||||
StopWatch(int id) : fStarted(false), fId(id), fOpenCalls(0), fOutputToFile(false), fLogFile("") {};
|
||||
StopWatch(const std::string& fileName) : fStarted(false), fId(-1), fOpenCalls(0), fOutputToFile(true), fLogFile(fileName) {}
|
||||
struct ::timeval fTvLast;
|
||||
int getId() { return fId; }
|
||||
class StopWatch
|
||||
{
|
||||
public:
|
||||
void start(const std::string& message);
|
||||
bool stop(const std::string& message, const int limit);
|
||||
void stop(const std::string& message);
|
||||
void finish();
|
||||
|
||||
private:
|
||||
class ProcessStats
|
||||
{
|
||||
public:
|
||||
|
||||
std::string fProcess;
|
||||
struct timeval fTvProcessStarted;
|
||||
double fTotalSeconds;
|
||||
int64_t fStartCount;
|
||||
int64_t fStopCount;
|
||||
bool isActive()
|
||||
{
|
||||
return fOpenCalls > 0;
|
||||
}
|
||||
StopWatch() : fStarted(false), fId(-1), fOpenCalls(0), fOutputToFile(false), fLogFile("") {};
|
||||
StopWatch(int id) : fStarted(false), fId(id), fOpenCalls(0), fOutputToFile(false), fLogFile("") {};
|
||||
StopWatch(const std::string& fileName) : fStarted(false), fId(-1), fOpenCalls(0), fOutputToFile(true), fLogFile(fileName) {}
|
||||
struct ::timeval fTvLast;
|
||||
int getId()
|
||||
{
|
||||
return fId;
|
||||
}
|
||||
|
||||
ProcessStats() : fProcess(""), fTotalSeconds(0.0), fStartCount(0), fStopCount(0) {};
|
||||
private:
|
||||
class ProcessStats
|
||||
{
|
||||
public:
|
||||
|
||||
void processStart()
|
||||
{
|
||||
gettimeofday(&fTvProcessStarted, 0);
|
||||
fStartCount++;
|
||||
}
|
||||
std::string fProcess;
|
||||
struct timeval fTvProcessStarted;
|
||||
double fTotalSeconds;
|
||||
int64_t fStartCount;
|
||||
int64_t fStopCount;
|
||||
|
||||
void processStop()
|
||||
{
|
||||
struct timeval tvStop;
|
||||
gettimeofday(&tvStop, 0);
|
||||
fStopCount++;
|
||||
fTotalSeconds +=
|
||||
(tvStop.tv_sec + (tvStop.tv_usec / 1000000.0)) -
|
||||
(fTvProcessStarted.tv_sec + (fTvProcessStarted.tv_usec / 1000000.0));
|
||||
ProcessStats() : fProcess(""), fTotalSeconds(0.0), fStartCount(0), fStopCount(0) {};
|
||||
|
||||
}
|
||||
};
|
||||
void processStart()
|
||||
{
|
||||
gettimeofday(&fTvProcessStarted, 0);
|
||||
fStartCount++;
|
||||
}
|
||||
|
||||
struct timeval fTvStart;
|
||||
std::vector <ProcessStats> fProcessStats;
|
||||
bool fStarted;
|
||||
int fId;
|
||||
int fOpenCalls;
|
||||
bool fOutputToFile;
|
||||
std::string fLogFile;
|
||||
void processStop()
|
||||
{
|
||||
struct timeval tvStop;
|
||||
gettimeofday(&tvStop, 0);
|
||||
fStopCount++;
|
||||
fTotalSeconds +=
|
||||
(tvStop.tv_sec + (tvStop.tv_usec / 1000000.0)) -
|
||||
(fTvProcessStarted.tv_sec + (fTvProcessStarted.tv_usec / 1000000.0));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
struct timeval fTvStart;
|
||||
std::vector <ProcessStats> fProcessStats;
|
||||
bool fStarted;
|
||||
int fId;
|
||||
int fOpenCalls;
|
||||
bool fOutputToFile;
|
||||
std::string fLogFile;
|
||||
};
|
||||
|
||||
} // end of logging namespace
|
||||
|
@ -28,170 +28,175 @@ using namespace std;
|
||||
using namespace logging;
|
||||
using namespace config;
|
||||
|
||||
class MessageLoggingTest : public CppUnit::TestFixture {
|
||||
class MessageLoggingTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE( MessageLoggingTest );
|
||||
CPPUNIT_TEST_SUITE( MessageLoggingTest );
|
||||
|
||||
CPPUNIT_TEST( m1 );
|
||||
CPPUNIT_TEST( m2 );
|
||||
CPPUNIT_TEST( m3 );
|
||||
CPPUNIT_TEST( m4 );
|
||||
CPPUNIT_TEST( m5 );
|
||||
CPPUNIT_TEST( m1 );
|
||||
CPPUNIT_TEST( m2 );
|
||||
CPPUNIT_TEST( m3 );
|
||||
CPPUNIT_TEST( m4 );
|
||||
CPPUNIT_TEST( m5 );
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
LoggingID lid;
|
||||
LoggingID lid;
|
||||
|
||||
public:
|
||||
void setUp() {
|
||||
setenv("CALPONT_CONFIG_FILE", "./Columnstore.xml", 1);
|
||||
}
|
||||
void setUp()
|
||||
{
|
||||
setenv("CALPONT_CONFIG_FILE", "./Columnstore.xml", 1);
|
||||
}
|
||||
|
||||
void tearDown() {
|
||||
}
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void m1()
|
||||
{
|
||||
Message::Args args;
|
||||
args.add("hello");
|
||||
args.add("world");
|
||||
args.add(123);
|
||||
args.add(1234.55);
|
||||
Message m(100);
|
||||
m.fMsg = "%1% %2% %3% %4%";
|
||||
m.format(args);
|
||||
//CPPUNIT_ASSERT(m.msg() == "hello world 123 1234.55");
|
||||
m.reset();
|
||||
m.fMsg = "%1% %2% %3% %4%";
|
||||
args.reset();
|
||||
m.format(args);
|
||||
//CPPUNIT_ASSERT(m.msg() == " ");
|
||||
LoggingID lid(7);
|
||||
MessageLog ml(lid);
|
||||
m.reset();
|
||||
args.add("hello");
|
||||
args.add("world");
|
||||
args.add(123);
|
||||
args.add(1234.55);
|
||||
m.format(args);
|
||||
ml.logDebugMessage(m);
|
||||
void m1()
|
||||
{
|
||||
Message::Args args;
|
||||
args.add("hello");
|
||||
args.add("world");
|
||||
args.add(123);
|
||||
args.add(1234.55);
|
||||
Message m(100);
|
||||
m.fMsg = "%1% %2% %3% %4%";
|
||||
m.format(args);
|
||||
//CPPUNIT_ASSERT(m.msg() == "hello world 123 1234.55");
|
||||
m.reset();
|
||||
m.fMsg = "%1% %2% %3% %4%";
|
||||
args.reset();
|
||||
m.format(args);
|
||||
//CPPUNIT_ASSERT(m.msg() == " ");
|
||||
LoggingID lid(7);
|
||||
MessageLog ml(lid);
|
||||
m.reset();
|
||||
args.add("hello");
|
||||
args.add("world");
|
||||
args.add(123);
|
||||
args.add(1234.55);
|
||||
m.format(args);
|
||||
ml.logDebugMessage(m);
|
||||
|
||||
args.reset();
|
||||
args.add("begin CEP generation");
|
||||
m.reset();
|
||||
m.format(args);
|
||||
ml.logInfoMessage(m);
|
||||
args.reset();
|
||||
args.add("begin CEP generation");
|
||||
m.reset();
|
||||
m.format(args);
|
||||
ml.logInfoMessage(m);
|
||||
|
||||
args.reset();
|
||||
args.add("end CEP generation");
|
||||
m.reset();
|
||||
m.format(args);
|
||||
ml.logInfoMessage(m);
|
||||
args.reset();
|
||||
args.add("end CEP generation");
|
||||
m.reset();
|
||||
m.format(args);
|
||||
ml.logInfoMessage(m);
|
||||
|
||||
args.reset();
|
||||
args.add("something took too long");
|
||||
m.reset();
|
||||
m.format(args);
|
||||
ml.logWarningMessage(m);
|
||||
args.reset();
|
||||
args.add("something took too long");
|
||||
m.reset();
|
||||
m.format(args);
|
||||
ml.logWarningMessage(m);
|
||||
|
||||
args.reset();
|
||||
args.add("something seriously took too long");
|
||||
m.reset();
|
||||
m.format(args);
|
||||
ml.logSeriousMessage(m);
|
||||
ml.logErrorMessage(m);
|
||||
args.reset();
|
||||
args.add("something seriously took too long");
|
||||
m.reset();
|
||||
m.format(args);
|
||||
ml.logSeriousMessage(m);
|
||||
ml.logErrorMessage(m);
|
||||
|
||||
args.reset();
|
||||
args.add("something critical took too long");
|
||||
m.reset();
|
||||
m.format(args);
|
||||
ml.logCriticalMessage(m);
|
||||
args.reset();
|
||||
args.add("something critical took too long");
|
||||
m.reset();
|
||||
m.format(args);
|
||||
ml.logCriticalMessage(m);
|
||||
|
||||
LoggingID lid1;
|
||||
MessageLog ml1(lid1);
|
||||
args.reset();
|
||||
m.reset();
|
||||
args.add("subsystem 0 = Calpont test");
|
||||
m.format(args);
|
||||
ml1.logDebugMessage(m);
|
||||
LoggingID lid1;
|
||||
MessageLog ml1(lid1);
|
||||
args.reset();
|
||||
m.reset();
|
||||
args.add("subsystem 0 = Calpont test");
|
||||
m.format(args);
|
||||
ml1.logDebugMessage(m);
|
||||
|
||||
LoggingID lid2(1000);
|
||||
MessageLog ml2(lid2);
|
||||
args.reset();
|
||||
m.reset();
|
||||
args.add("subsystem above MAX = Calpont test");
|
||||
m.format(args);
|
||||
ml2.logDebugMessage(m);
|
||||
LoggingID lid2(1000);
|
||||
MessageLog ml2(lid2);
|
||||
args.reset();
|
||||
m.reset();
|
||||
args.add("subsystem above MAX = Calpont test");
|
||||
m.format(args);
|
||||
ml2.logDebugMessage(m);
|
||||
|
||||
LoggingID lid3(7);
|
||||
MessageLog ml3(lid3);
|
||||
args.reset();
|
||||
m.reset();
|
||||
args.add("subsystem 7 = mcsadmin test");
|
||||
m.format(args);
|
||||
ml3.logDebugMessage(m);
|
||||
LoggingID lid3(7);
|
||||
MessageLog ml3(lid3);
|
||||
args.reset();
|
||||
m.reset();
|
||||
args.add("subsystem 7 = mcsadmin test");
|
||||
m.format(args);
|
||||
ml3.logDebugMessage(m);
|
||||
Config::deleteInstanceMap();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void m2()
|
||||
{
|
||||
Message m1(100);
|
||||
CPPUNIT_ASSERT(m1.msgID() == 100);
|
||||
Message m2(10);
|
||||
CPPUNIT_ASSERT(m2.msgID() == 10);
|
||||
m2 = m1;
|
||||
CPPUNIT_ASSERT(m2.msgID() == 100);
|
||||
Message m3(m2);
|
||||
CPPUNIT_ASSERT(m3.msgID() == m2.msgID());
|
||||
Message m4(99);
|
||||
Message m5(199);
|
||||
CPPUNIT_ASSERT(m4.msgID() == 99);
|
||||
CPPUNIT_ASSERT(m5.msgID() == 199);
|
||||
m4.swap(m5);
|
||||
CPPUNIT_ASSERT(m5.msgID() == 99);
|
||||
CPPUNIT_ASSERT(m4.msgID() == 199);
|
||||
void m2()
|
||||
{
|
||||
Message m1(100);
|
||||
CPPUNIT_ASSERT(m1.msgID() == 100);
|
||||
Message m2(10);
|
||||
CPPUNIT_ASSERT(m2.msgID() == 10);
|
||||
m2 = m1;
|
||||
CPPUNIT_ASSERT(m2.msgID() == 100);
|
||||
Message m3(m2);
|
||||
CPPUNIT_ASSERT(m3.msgID() == m2.msgID());
|
||||
Message m4(99);
|
||||
Message m5(199);
|
||||
CPPUNIT_ASSERT(m4.msgID() == 99);
|
||||
CPPUNIT_ASSERT(m5.msgID() == 199);
|
||||
m4.swap(m5);
|
||||
CPPUNIT_ASSERT(m5.msgID() == 99);
|
||||
CPPUNIT_ASSERT(m4.msgID() == 199);
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
}
|
||||
|
||||
void m3()
|
||||
{
|
||||
LoggingID lid1(1, 2, 3, 4);
|
||||
MessageLog ml1(lid1);
|
||||
CPPUNIT_ASSERT(ml1.fLogData.fSubsysID == 1);
|
||||
void m3()
|
||||
{
|
||||
LoggingID lid1(1, 2, 3, 4);
|
||||
MessageLog ml1(lid1);
|
||||
CPPUNIT_ASSERT(ml1.fLogData.fSubsysID == 1);
|
||||
|
||||
LoggingID lid2(10, 20, 30, 40);
|
||||
MessageLog ml2(lid2);
|
||||
CPPUNIT_ASSERT(ml2.fLogData.fSubsysID == 10);
|
||||
LoggingID lid2(10, 20, 30, 40);
|
||||
MessageLog ml2(lid2);
|
||||
CPPUNIT_ASSERT(ml2.fLogData.fSubsysID == 10);
|
||||
|
||||
ml2 = ml1;
|
||||
CPPUNIT_ASSERT(ml2.fLogData.fSubsysID == 1);
|
||||
ml2 = ml1;
|
||||
CPPUNIT_ASSERT(ml2.fLogData.fSubsysID == 1);
|
||||
|
||||
MessageLog ml3(ml2);
|
||||
CPPUNIT_ASSERT(ml3.fLogData.fSubsysID == 1);
|
||||
MessageLog ml3(ml2);
|
||||
CPPUNIT_ASSERT(ml3.fLogData.fSubsysID == 1);
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
}
|
||||
|
||||
void m4()
|
||||
{
|
||||
LoggingID lid1(100, 200, 300, 400);
|
||||
MessageLog ml1(lid1);
|
||||
Message::Args args;
|
||||
Message* m;
|
||||
args.add("hello");
|
||||
args.add("world");
|
||||
args.add(123);
|
||||
args.add(1234.55);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
m = new Message(i);
|
||||
m->format(args);
|
||||
ml1.logDebugMessage(*m);
|
||||
delete m;
|
||||
}
|
||||
|
||||
void m4()
|
||||
{
|
||||
LoggingID lid1(100, 200, 300, 400);
|
||||
MessageLog ml1(lid1);
|
||||
Message::Args args;
|
||||
Message* m;
|
||||
args.add("hello");
|
||||
args.add("world");
|
||||
args.add(123);
|
||||
args.add(1234.55);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
m = new Message(i);
|
||||
m->format(args);
|
||||
ml1.logDebugMessage(*m);
|
||||
delete m;
|
||||
}
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// This method is intended to test the messages used to profile db performance.
|
||||
@ -255,103 +260,104 @@ void m4()
|
||||
// this way is that a derived class like MessageLogStatement "could" be
|
||||
// implemented to log the StartStatement, and its desctructor could then
|
||||
// log the EndStatement automatically, on behalf of the application.
|
||||
//
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
void m5()
|
||||
{
|
||||
void m5()
|
||||
{
|
||||
int subSystem = 5; // joblist subSystem
|
||||
int session = 100;
|
||||
int transaction = 1;
|
||||
int thread = 0;
|
||||
|
||||
LoggingID lid1 ( subSystem, session, transaction, thread );
|
||||
MessageLog msgLog ( lid1 );
|
||||
int thread = 0;
|
||||
|
||||
Message::Args args;
|
||||
LoggingID lid1 ( subSystem, session, transaction, thread );
|
||||
MessageLog msgLog ( lid1 );
|
||||
|
||||
// Log the start time of a transaction
|
||||
Message msgStartTrans ( M0026 );
|
||||
msgStartTrans.format ( args );
|
||||
msgLog.logDebugMessage ( msgStartTrans );
|
||||
Message::Args args;
|
||||
|
||||
// Log the start of execution time for a SQL statement
|
||||
Message msgStartStatement ( M0028 );
|
||||
int statementId = 11;
|
||||
int versionId = 22;
|
||||
string sql ("SELECT column1, column2 FROM table1 WHERE column1 = 345");
|
||||
args.reset ( );
|
||||
args.add ( statementId );
|
||||
args.add ( versionId );
|
||||
args.add ( sql );
|
||||
msgStartStatement.format ( args );
|
||||
msgLog.logDebugMessage ( msgStartStatement );
|
||||
// Log the start time of a transaction
|
||||
Message msgStartTrans ( M0026 );
|
||||
msgStartTrans.format ( args );
|
||||
msgLog.logDebugMessage ( msgStartTrans );
|
||||
|
||||
const string stepNames[] = { "steponeA", "steptwoA" ,"stepthreeA",
|
||||
"stepfourB","stepfiveB","stepsixB" };
|
||||
// Log the start of execution time for a SQL statement
|
||||
Message msgStartStatement ( M0028 );
|
||||
int statementId = 11;
|
||||
int versionId = 22;
|
||||
string sql ("SELECT column1, column2 FROM table1 WHERE column1 = 345");
|
||||
args.reset ( );
|
||||
args.add ( statementId );
|
||||
args.add ( versionId );
|
||||
args.add ( sql );
|
||||
msgStartStatement.format ( args );
|
||||
msgLog.logDebugMessage ( msgStartStatement );
|
||||
|
||||
// To process this SQL statement, simulate executing 2 job steps,
|
||||
// with each job step consisting of of 3 parallel primitive steps
|
||||
for (int jobStep=0; jobStep<2; jobStep++)
|
||||
{
|
||||
int primStep1 = jobStep * 3;
|
||||
const string stepNames[] = { "steponeA", "steptwoA", "stepthreeA",
|
||||
"stepfourB", "stepfiveB", "stepsixB"
|
||||
};
|
||||
|
||||
// Log 3 parallel steps starting to execute
|
||||
for (int i=primStep1; i<(primStep1+3); i++)
|
||||
{
|
||||
Message msgStartStep ( M0030 ); // Start Step
|
||||
int stepId = i+1;
|
||||
string stepName = stepNames[i];
|
||||
args.reset ( );
|
||||
args.add ( statementId );
|
||||
args.add ( stepId );
|
||||
args.add ( stepName );
|
||||
msgStartStep.format ( args );
|
||||
msgLog.logDebugMessage ( msgStartStep );
|
||||
}
|
||||
// To process this SQL statement, simulate executing 2 job steps,
|
||||
// with each job step consisting of of 3 parallel primitive steps
|
||||
for (int jobStep = 0; jobStep < 2; jobStep++)
|
||||
{
|
||||
int primStep1 = jobStep * 3;
|
||||
|
||||
// Record I/O block count for 0 or more objects per step;
|
||||
// for this example we just record I/O for 1 object per step.
|
||||
// Then log the completion of each step.
|
||||
for (int i=primStep1; i<(primStep1+3); i++)
|
||||
{
|
||||
Message msgBlockCount ( M0032 ); // I/O block count
|
||||
int stepId = i+1;
|
||||
int objectId = stepId * 20;
|
||||
int phyCount = stepId * 30;
|
||||
int logCount = phyCount + 5;
|
||||
args.reset ( );
|
||||
args.add ( statementId );
|
||||
args.add ( stepId );
|
||||
args.add ( objectId );
|
||||
args.add ( phyCount );
|
||||
args.add ( logCount );
|
||||
msgBlockCount.format ( args );
|
||||
msgLog.logDebugMessage ( msgBlockCount );
|
||||
// Log 3 parallel steps starting to execute
|
||||
for (int i = primStep1; i < (primStep1 + 3); i++)
|
||||
{
|
||||
Message msgStartStep ( M0030 ); // Start Step
|
||||
int stepId = i + 1;
|
||||
string stepName = stepNames[i];
|
||||
args.reset ( );
|
||||
args.add ( statementId );
|
||||
args.add ( stepId );
|
||||
args.add ( stepName );
|
||||
msgStartStep.format ( args );
|
||||
msgLog.logDebugMessage ( msgStartStep );
|
||||
}
|
||||
|
||||
Message msgEndStep ( M0031 ); // End Step
|
||||
args.reset ( );
|
||||
args.add ( statementId );
|
||||
args.add ( stepId );
|
||||
msgEndStep.format ( args );
|
||||
msgLog.logDebugMessage ( msgEndStep );
|
||||
}
|
||||
}
|
||||
// Record I/O block count for 0 or more objects per step;
|
||||
// for this example we just record I/O for 1 object per step.
|
||||
// Then log the completion of each step.
|
||||
for (int i = primStep1; i < (primStep1 + 3); i++)
|
||||
{
|
||||
Message msgBlockCount ( M0032 ); // I/O block count
|
||||
int stepId = i + 1;
|
||||
int objectId = stepId * 20;
|
||||
int phyCount = stepId * 30;
|
||||
int logCount = phyCount + 5;
|
||||
args.reset ( );
|
||||
args.add ( statementId );
|
||||
args.add ( stepId );
|
||||
args.add ( objectId );
|
||||
args.add ( phyCount );
|
||||
args.add ( logCount );
|
||||
msgBlockCount.format ( args );
|
||||
msgLog.logDebugMessage ( msgBlockCount );
|
||||
|
||||
// Log the completion time of the SQL statement
|
||||
Message msgEndStatement ( M0029 );
|
||||
args.reset ( );
|
||||
args.add ( statementId );
|
||||
msgEndStatement.format ( args );
|
||||
msgLog.logDebugMessage ( msgEndStatement );
|
||||
Message msgEndStep ( M0031 ); // End Step
|
||||
args.reset ( );
|
||||
args.add ( statementId );
|
||||
args.add ( stepId );
|
||||
msgEndStep.format ( args );
|
||||
msgLog.logDebugMessage ( msgEndStep );
|
||||
}
|
||||
}
|
||||
|
||||
// Log the completion time of the transaction
|
||||
Message msgEndTrans ( M0027 );
|
||||
args.reset ( );
|
||||
args.add ( string("COMMIT") );
|
||||
msgEndTrans.format ( args );
|
||||
msgLog.logDebugMessage ( msgEndTrans );
|
||||
// Log the completion time of the SQL statement
|
||||
Message msgEndStatement ( M0029 );
|
||||
args.reset ( );
|
||||
args.add ( statementId );
|
||||
msgEndStatement.format ( args );
|
||||
msgLog.logDebugMessage ( msgEndStatement );
|
||||
|
||||
// Log the completion time of the transaction
|
||||
Message msgEndTrans ( M0027 );
|
||||
args.reset ( );
|
||||
args.add ( string("COMMIT") );
|
||||
msgEndTrans.format ( args );
|
||||
msgLog.logDebugMessage ( msgEndTrans );
|
||||
Config::deleteInstanceMap();
|
||||
}
|
||||
}
|
||||
|
||||
}; // end of CppUnit::TestFixture class
|
||||
|
||||
@ -360,12 +366,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION( MessageLoggingTest );
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
int main( int argc, char **argv)
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest( registry.makeTest() );
|
||||
bool wasSuccessful = runner.run( "", false );
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest( registry.makeTest() );
|
||||
bool wasSuccessful = runner.run( "", false );
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user