15 #include <boost/regex.hpp>
36 :
std::ostream(
std::cout.rdbuf())
76 options->
AddOptions(
"Logging options")(
"QwLog.color",
77 po::value<bool>()->default_value(
true),
78 "colored screen output");
79 options->
AddOptions(
"Logging options")(
"QwLog.logfile",
82 options->
AddOptions(
"Logging options")(
"QwLog.loglevel-file",
83 po::value<int>()->default_value(
kMessage),
84 "log level for file output");
85 options->
AddOptions(
"Logging options")(
"QwLog.loglevel-screen",
86 po::value<int>()->default_value(
kMessage),
87 "log level for screen output");
88 options->
AddOptions(
"Logging options")(
"QwLog.print-signature",
90 "print signature on error or warning");
91 options->
AddOptions(
"Logging options")(
"QwLog.debug-function",
92 po::value< std::vector<string> >()->multitoken(),
93 "print debugging output of function with signatures satisfying the specified regex");
111 if (options->
HasValue(
"QwLog.logfile"))
126 if (fDebugFunctionRegexString.size() > 0)
127 std::cout <<
"Debug regex list:" << std::endl;
128 for (
size_t i = 0; i < fDebugFunctionRegexString.size(); i++) {
129 std::cout << fDebugFunctionRegexString.back() << std::endl;
146 if (boost::regex_match(func_sig,
regex)) {
164 std::ios_base::openmode flags = std::ios::out | mode;
165 fFile =
new std::ofstream(name.c_str(), flags);
194 const std::string func_sig)
212 *(
fScreen) <<
"Error (in " << func_sig <<
"): ";
222 *(
fScreen) <<
"Warning (in " << func_sig <<
"): ";
247 default: *(
fFile) <<
" ";
break;
305 *(gQwLog.
fScreen) << std::endl;
310 *(gQwLog.
fFile) << std::endl;
322 *(gQwLog.
fScreen) << std::flush;
325 *(gQwLog.
fFile) << std::flush;
334 time_t now = time(0);
336 struct tm *currentTime = localtime(&now);
337 strftime(
fTimeString, 128,
"%Y-%m-%d, %T", currentTime);
void InitLogFile(const std::string name, const std::ios_base::openmode mode=kAppend)
Initialize the log file with name 'name'.
std::vector< std::string > fDebugFunctionRegexString
QwLogLevel fFileThreshold
File thresholds and stream.
#define default_bool_value(b)
static bool fScreenAtNewLine
void SetScreenThreshold(int thr)
Set the screen log level.
bool HasValue(const std::string &key)
Has this key been defined.
static bool fFileAtNewLine
Flags only relevant for current line, but static for use in static function.
QwLogLevel fScreenThreshold
Screen thresholds and stream.
std::vector< T > GetValueVector(const std::string &key)
Get a list of templated values.
static const std::ios_base::openmode kAppend
void ProcessOptions(QwOptions *options)
Process class options for QwOptions.
QwLog & operator<<(const T &t)
Stream an object to the output stream.
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
static const std::ios_base::openmode kTruncate
Log file open modes.
T GetValue(const std::string &key)
Get a templated value.
void SetScreenColor(bool flag)
Set the screen color mode.
const char * GetTime()
Get the local time.
void SetFileThreshold(int thr)
Set the file log level.
virtual ~QwLog()
The destructor.
std::map< std::string, bool > fIsDebugFunction
List of regular expressions for functions that will have increased log level.
A logfile class, based on an identical class in the Hermes analyzer.
bool fPrintFunctionSignature
Flag to print function signature on warning or error.
static void DefineOptions(QwOptions *options)
Define available class options for QwOptions.
QwLogLevel fLogLevel
Log level of this stream.
QwLog & operator()(const QwLogLevel level, const std::string func_sig="<unknown>")
Set the stream log level.
A color changing class for the output stream.
bool fUseColor
Flag to disable color.
static bool fScreenInColor
static std::ostream & endl(std::ostream &)
End of the line.
An options class which parses command line, config file and environment.
bool IsDebugFunction(const string func_name)
Determine whether the function name matches a specified list of regular expressions.
static std::ostream & flush(std::ostream &)
Flush the streams.