JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwLog Class Reference

Logging and output management system with configurable verbosity levels. More...

#include <QwLog.h>

+ Inheritance diagram for QwLog:
+ Collaboration diagram for QwLog:

Public Types

enum  QwLogLevel {
  kAlways = -1 , kError = 0 , kWarning = 1 , kMessage = 2 ,
  kVerbose = 3 , kDebug = 4
}
 Loglevels. More...
 

Public Member Functions

void ProcessOptions (QwOptions *options)
 Process class options for QwOptions.
 
 QwLog ()
 The constructor.
 
 ~QwLog () override
 The destructor.
 
bool IsDebugFunction (const string func_name)
 Determine whether the function name matches a specified list of regular expressions.
 
void InitLogFile (const std::string name, const std::ios_base::openmode mode=kAppend)
 Initialize the log file with name 'name'.
 
void SetScreenColor (bool flag)
 Set the screen color mode.
 
void SetScreenThreshold (int thr)
 Set the screen log level.
 
void SetFileThreshold (int thr)
 Set the file log level.
 
QwLogLevel GetLogLevel () const
 Get highest log level.
 
QwLogoperator() (const QwLogLevel level, const std::string func_sig="<unknown>")
 Set the stream log level.
 
template<class T>
QwLogoperator<< (const T &t)
 Stream an object to the output stream.
 
QwLogoperator<< (std::ostream &(*manip)(std::ostream &))
 Pass the ios_base manipulators.
 

Static Public Member Functions

static void DefineOptions (QwOptions *options)
 Define available class options for QwOptions.
 
static std::ostream & endl (std::ostream &)
 End of the line.
 
static std::ostream & flush (std::ostream &)
 Flush the streams.
 

Static Public Attributes

static const std::ios_base::openmode kTruncate = std::ios::trunc
 Log file open modes.
 
static const std::ios_base::openmode kAppend = std::ios::app
 

Private Member Functions

const char * GetTime ()
 Get the local time.
 

Private Attributes

char fTimeString [128]
 
QwLogLevel fScreenThreshold
 Screen thresholds and stream.
 
std::ostream * fScreen
 
QwLogLevel fFileThreshold
 File thresholds and stream.
 
std::ostream * fFile
 
QwLogLevel fLogLevel
 Log level of this stream.
 
bool fPrintFunctionSignature
 Flag to print function signature on warning or error.
 
std::map< std::string, bool > fIsDebugFunction
 List of regular expressions for functions that will have increased log level.
 
std::vector< std::string > fDebugFunctionRegexString
 
bool fUseColor
 Flag to disable color.
 

Static Private Attributes

static bool fFileAtNewLine = true
 Flags only relevant for current line, but static for use in static function.
 
static bool fScreenInColor = false
 
static bool fScreenAtNewLine = true
 

Detailed Description

Logging and output management system with configurable verbosity levels.

Provides a hierarchical logging system with multiple output levels (Error, Warning, Message, Verbose, Debug) and predefined log drains (QwError, QwWarning, QwMessage, QwVerbose, QwDebug). Supports output redirection to files, colored output, and function-specific debugging. Should not be used directly; use the predefined macros instead.

Definition at line 73 of file QwLog.h.

Member Enumeration Documentation

◆ QwLogLevel

Loglevels.

enum of possible log levels

Enumerator
kAlways 

Explicit output

kError 

Error loglevel

kWarning 

Warning loglevel

kMessage 

Message loglevel

kVerbose 

Verbose loglevel

kDebug 

Debug loglevel

Definition at line 88 of file QwLog.h.

88 {
89 kAlways = -1, /*!< Explicit output */
90 kError = 0, /*!< Error loglevel */
91 kWarning = 1, /*!< Warning loglevel */
92 kMessage = 2, /*!< Message loglevel */
93 kVerbose = 3, /*!< Verbose loglevel */
94 kDebug = 4 /*!< Debug loglevel */
95 };
@ kError
Definition QwLog.h:90
@ kVerbose
Definition QwLog.h:93
@ kDebug
Definition QwLog.h:94
@ kMessage
Definition QwLog.h:92
@ kAlways
Definition QwLog.h:89
@ kWarning
Definition QwLog.h:91

Constructor & Destructor Documentation

◆ QwLog()

QwLog::QwLog ( )

The constructor.

The constructor initializes the screen stream and resets the file stream

Definition at line 33 of file QwLog.cc.

34: std::ostream(std::cout.rdbuf())
35{
37 fScreen = &std::cout;
38
40 fFile = 0;
41
43
44 fUseColor = true;
45
47}
QwLogLevel fLogLevel
Log level of this stream.
Definition QwLog.h:181
bool fPrintFunctionSignature
Flag to print function signature on warning or error.
Definition QwLog.h:184
bool fUseColor
Flag to disable color.
Definition QwLog.h:191
std::ostream * fScreen
Definition QwLog.h:176
QwLogLevel fScreenThreshold
Screen thresholds and stream.
Definition QwLog.h:175
std::ostream * fFile
Definition QwLog.h:179
QwLogLevel fFileThreshold
File thresholds and stream.
Definition QwLog.h:178

References fFile, fFileThreshold, fLogLevel, fPrintFunctionSignature, fScreen, fScreenThreshold, fUseColor, and kMessage.

Referenced by operator()(), operator<<(), and operator<<().

+ Here is the caller graph for this function:

◆ ~QwLog()

QwLog::~QwLog ( )
override

The destructor.

The destructor destroys the log file, if it was present

Definition at line 51 of file QwLog.cc.

52{
53 if (fFile) {
54 delete fFile;
55 fFile = 0;
56 }
57}

References fFile.

Member Function Documentation

◆ DefineOptions()

void QwLog::DefineOptions ( QwOptions * options)
static

Define available class options for QwOptions.

Defines configuration options for logging class using QwOptions functionality.

Note: this uses a pointer as opposed to a reference, because as indicated above the QwLog class cannot depend on the QwOptions class. When using a pointer we only need a forward declaration and we do not need to include the header file QwOptions.h.

Parameters
optionsOptions object

Definition at line 71 of file QwLog.cc.

72{
73 // Define the logging options
74 options->AddOptions("Logging options")("QwLog.color",
75 po::value<bool>()->default_value(true),
76 "colored screen output");
77 options->AddOptions("Logging options")("QwLog.logfile",
78 po::value<string>(),
79 "log file");
80 options->AddOptions("Logging options")("QwLog.loglevel-file",
81 po::value<int>()->default_value(kMessage),
82 "log level for file output");
83 options->AddOptions("Logging options")("QwLog.loglevel-screen",
84 po::value<int>()->default_value(kMessage),
85 "log level for screen output");
86 options->AddOptions("Logging options")("QwLog.print-signature",
87 po::value<bool>()->default_bool_value(false),
88 "print signature on error or warning");
89 options->AddOptions("Logging options")("QwLog.debug-function",
90 po::value< std::vector<string> >()->multitoken(),
91 "print debugging output of function with signatures satisfying the specified regex");
92}
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Definition QwOptions.h:170

References QwOptions::AddOptions(), and kMessage.

Referenced by QwOptions::DefineOptions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ endl()

std::ostream & QwLog::endl ( std::ostream & strm)
static

End of the line.

End of the line

Definition at line 297 of file QwLog.cc.

298{
300 if (fScreenInColor)
301 *(gQwLog.fScreen) << QwColor(Qw::kNormal) << std::endl;
302 else
303 *(gQwLog.fScreen) << std::endl;
304 fScreenAtNewLine = true;
305 fScreenInColor = false;
306 }
308 *(gQwLog.fFile) << std::endl;
309 fFileAtNewLine = true;
310 }
311
312 return strm;
313}
QwLog gQwLog
Definition QwLog.cc:20
@ kNormal
Definition QwColor.h:81
static bool fScreenInColor
Definition QwLog.h:195
static bool fFileAtNewLine
Flags only relevant for current line, but static for use in static function.
Definition QwLog.h:194
static bool fScreenAtNewLine
Definition QwLog.h:196

References fFileAtNewLine, fScreenAtNewLine, fScreenInColor, gQwLog, and Qw::kNormal.

Referenced by __attribute__(), QwDataHandlerArray::AccumulateAllRunningSum(), QwSubsystemArrayParity::AccumulateAllRunningSum(), QwADC18_Channel::AccumulateRunningSum(), QwCorrelator::AccumulateRunningSum(), QwDataHandlerArray::AccumulateRunningSum(), QwHelicityCorrelatedFeedback::AccumulateRunningSum(), QwMollerADC_Channel::AccumulateRunningSum(), QwSubsystemArrayParity::AccumulateRunningSum(), QwVQWK_Channel::AccumulateRunningSum(), VQwHardwareChannel::AccumulateRunningSum(), VQwScaler_Channel::AccumulateRunningSum(), QwOptions::AddConfigFile(), QwPromptSummary::AddElement(), QwDBInterface::AddThisEntryToList(), QwErrDBInterface::AddThisEntryToList(), QwHelicityCorrelatedFeedback::ApplyFeedbackCorrections(), QwHelicityCorrelatedFeedback::ApplyHAIAFeedback(), QwADC18_Channel::ApplyHWChecks(), QwMollerADC_Channel::ApplyHWChecks(), QwVQWK_Channel::ApplyHWChecks(), QwHelicityCorrelatedFeedback::ApplyIAFeedback(), QwHelicityCorrelatedFeedback::ApplyPITAFeedback(), QwSubsystemArray::AtEndOfEventLoop(), VQwSubsystem::AtEndOfEventLoop(), QwSubsystemArrayParity::Blind(), QwSubsystemArrayParity::Blind(), QwHelicity::BuildHelicityBitPattern(), QwCorrelator::CalcCorrelations(), VQwDataHandler::CalcOneOutput(), QwHelicityCorrelatedFeedback::CalculateAsymmetry(), QwHelicityPattern::CalculateAsymmetry(), QwCombinedBPM< T >::CalculateFixedParameter(), QwHelicityPattern::CalculatePairAsymmetry(), QwSubsystemArray::CanContain(), QwAlarmHandler::CheckAlarms(), QwBlinder::CheckBlindability(), QwSubsystemArrayParity::CheckForBurpFail(), QwEventBuffer::CheckForMarkerWords(), QwHelicity::CheckPatternNum(), QwBlinder::CheckTestValues(), VQwCloneable< base_t >::Clone(), QwCorrelator::CloseAliasFile(), QwEventBuffer::CloseStream(), QwEventBuffer::CloseThisSegment(), QwHelicity::CollectRandBits24(), QwHelicity::CollectRandBits30(), QwDatabase::Connect(), LRBCorrector::ConnectChannels(), QwAlarmHandler::ConnectChannels(), QwCombiner::ConnectChannels(), QwCombiner::ConnectChannels(), QwCorrelator::ConnectChannels(), QwExtractor::ConnectChannels(), VQwDataHandler::ConnectChannels(), QwBCM< T >::ConstructBranch(), QwBPMCavity::ConstructBranch(), QwBPMStripline< T >::ConstructBranch(), QwClock< T >::ConstructBranch(), QwCombinedBPM< T >::ConstructBranch(), QwCombinedPMT::ConstructBranch(), QwEnergyCalculator::ConstructBranch(), QwHaloMonitor::ConstructBranch(), QwIntegrationPMT::ConstructBranch(), QwLinearDiodeArray::ConstructBranch(), QwQPD::ConstructBranch(), QwSubsystemArray::ConstructBranch(), QwEPICSEvent::ConstructBranchAndVector(), QwMollerADC_Channel::ConstructBranchAndVector(), QwRootTree::ConstructBranchAndVector(), QwVQWK_Channel::ConstructBranchAndVector(), QwHelicity::ConstructHistograms(), QwRootFile::ConstructHistograms(), QwRootTree::ConstructNewTree(), VQwDataHandler::ConstructNTupleFields(), QwRootFile::ConstructObjects(), QwCorrelator::ConstructTreeBranches(), QwExtractor::ConstructTreeBranches(), VQwDataHandler::ConstructTreeBranches(), VQwBCM::Create(), VQwClock::Create(), VQwBCM::CreateCombo(), VQwBPM::CreateCombo(), VQwBPM::CreateStripline(), QwEventBuffer::DataFileIsSegmented(), QwSubsystemArrayParity::DeaccumulateRunningSum(), Coda2EventDecoder::DecodeEventIDBank(), Coda3EventDecoder::DecodeEventIDBank(), VEventDecoder::DecodeSubbankHeader(), QwEPICSEvent::DetermineIHWPPolarity(), QwDBInterface::DetermineMeasurementTypeID(), QwADC18_Channel::EncodeEventData(), QwHelicity::EncodeEventData(), VQwDetectorArray::ExchangeProcessedData(), QwHelicityCorrelatedFeedback::FeedHAIASetPoint(), QwHelicityCorrelatedFeedback::FeedIASetPoint(), QwHelicityCorrelatedFeedback::FeedPITASetPoints(), QwRootTree::Fill(), QwEventBuffer::FillEPICSData(), QwHelicity::FillHistograms(), QwEventBuffer::FillSubsystemConfigurationData(), QwEventBuffer::FillSubsystemData(), QwRootTree::FillTreeBranches(), QwADC18_Channel::FillTreeVector(), QwEPICSEvent::FillTreeVector(), QwScaler_Channel< data_mask, data_shift >::FillTreeVector(), QwParameterFile::FindFile(), QwADC18_Channel::GetBufferOffset(), QwMollerADC_Channel::GetBufferOffset(), QwVQWK_Channel::GetBufferOffset(), VQwScaler_Channel::GetBufferOffset(), VQwDetectorArray::GetCombinedPMT(), getenv_safe(), VQwFactory< base_t >::GetFactory(), QwHelicityCorrelatedFeedback::GetHAChargeStat(), QwHistogramHelper::GetHistParamsFromFile(), QwHistogramHelper::GetHistParamsFromLine(), QwHistogramHelper::GetHistParamsFromList(), VQwDetectorArray::GetIntegrationPMT(), QwEventBuffer::GetNextEvent(), QwEventBuffer::GetNextEventRange(), QwEventBuffer::GetNextRunRange(), QwHelicity::GetRandbit24(), QwHelicity::GetRandbit30(), QwHelicity::GetRandomSeed(), QwHelicityCorrelatedFeedback::GetTargetChargeStat(), QwHelicityCorrelatedFeedback::GetTargetChargeStat(), QwOptions::GetValue(), QwParameterFile::HasValue(), QwBlinder::InitBlinders(), QwBlinder::InitTestValues(), Coda3EventDecoder::InterpretBankTag(), QwHelicity::IsGoodEventNumber(), QwHelicity::IsGoodHelicity(), QwHelicity::IsGoodPatternNumber(), QwHelicity::IsGoodPhaseNumber(), LinRegBevPeb::LinRegBevPeb(), QwOptions::ListConfigFiles(), MQwPublishable< U, T >::ListPublishedValues(), VQwFactory< base_t >::ListRegisteredTypes(), QwSubsystemArray::LoadAllEventRanges(), LRBCorrector::LoadChannelMap(), QwBeamLine::LoadChannelMap(), QwBeamMod::LoadChannelMap(), QwCombiner::LoadChannelMap(), QwCorrelator::LoadChannelMap(), QwEPICSEvent::LoadChannelMap(), QwHelicity::LoadChannelMap(), QwScaler::LoadChannelMap(), VQwDetectorArray::LoadChannelMap(), QwADC18_Channel::LoadChannelParameters(), QwMollerADC_Channel::LoadChannelParameters(), QwVQWK_Channel::LoadChannelParameters(), QwDataHandlerArray::LoadDataHandlersFromParameterFile(), QwPromptSummary::LoadElementsFromParameterFile(), QwPromptSummary::LoadElementsFromParameterFile(), QwBeamLine::LoadEventCuts_Line(), QwBeamMod::LoadEventCuts_Line(), VQwDetectorArray::LoadEventCuts_Line(), QwHelicityPattern::LoadEventData(), QwBeamLine::LoadGeometryDefinition(), QwHistogramHelper::LoadHistParamsFromFile(), QwScaler::LoadInputParameters(), QwBeamLine::LoadMockDataParameters(), QwSubsystemArrayParity::LoadMockDataParameters(), QwHelicityCorrelatedFeedback::LoadParameterFile(), QwSubsystemArray::LoadSubsystemsFromParameterFile(), QwHistogramHelper::LoadTreeParamsFromFile(), main(), main(), QwHistogramHelper::MatchDeviceParamsFromList(), QwHistogramHelper::MatchVQWKElementFromList(), QwCorrelator::OpenAliasFile(), QwCorrelator::OpenAlphaFile(), QwEventBuffer::OpenDataFile(), QwParameterFile::OpenFile(), QwEventBuffer::OpenNextSegment(), QwEventBuffer::OpenNextStream(), QwHelicity::operator+=(), QwSubsystemArrayParity::operator+=(), QwADC18_Channel::operator/=(), QwMollerADC_Channel::operator/=(), QwVQWK_Channel::operator/=(), VQwScaler_Channel::operator/=(), QwDataHandlerArray::operator=(), QwSubsystemArray::operator=(), QwBPMCavity::ParseChannelName(), QwOptions::ParseCommandLine(), QwCorrelator::ParseConfigFile(), QwOptions::ParseConfigFile(), VQwDataHandler::ParseConfigFile(), QwOptions::ParseEnvironment(), QwParameterFile::ParseInt(), QwParameterFile::ParseIntRange(), QwEventRing::pop(), QwBeamMod::Print(), QwHelicity::Print(), QwHelicityPattern::Print(), QwModChannelID::Print(), QwRootTree::Print(), QwWord::Print(), LinRegBevPeb::print(), QwBlinder::PrintCountersValues(), QwPromptSummary::PrintCSVHeader(), Coda2EventDecoder::PrintDecoderInfo(), Coda3EventDecoder::PrintDecoderInfo(), VEventDecoder::PrintDecoderInfo(), VQwSubsystem::PrintDetectorMaps(), QwRootFile::PrintDirs(), QwADC18_Channel::PrintErrorCounterHead(), QwMollerADC_Channel::PrintErrorCounterHead(), QwVQWK_Channel::PrintErrorCounterHead(), QwADC18_Channel::PrintErrorCounters(), QwBeamLine::PrintErrorCounters(), QwHelicity::PrintErrorCounters(), QwMollerADC_Channel::PrintErrorCounters(), QwVQWK_Channel::PrintErrorCounters(), VQwDetectorArray::PrintErrorCounters(), VQwScaler_Channel::PrintErrorCounters(), QwADC18_Channel::PrintErrorCounterTail(), QwMollerADC_Channel::PrintErrorCounterTail(), QwVQWK_Channel::PrintErrorCounterTail(), QwBlinder::PrintFinalValues(), QwHistogramHelper::PrintHistParams(), QwWord::PrintID(), QwHelicityPattern::PrintIndexMapFile(), QwADC18_Channel::PrintInfo(), QwScaler::PrintInfo(), VQwScaler_Channel::PrintInfo(), QwEventBuffer::PrintRunTimes(), QwDBInterface::PrintStatus(), QwErrDBInterface::PrintStatus(), LinRegBevPeb::printSummaryAlphas(), LinRegBevPeb::printSummaryMeansWithUnc(), LinRegBevPeb::printSummaryMeansWithUncCorrected(), LinRegBevPeb::printSummaryP(), LinRegBevPeb::printSummaryY(), LinRegBevPeb::printSummaryYP(), QwRootFile::PrintTrees(), Coda3EventDecoder::printUserEvent(), QwADC18_Channel::PrintValue(), QwBeamLine::PrintValue(), QwHelicityPattern::PrintValue(), QwMollerADC_Channel::PrintValue(), QwPMT_Channel::PrintValue(), QwScaler::PrintValue(), QwVQWK_Channel::PrintValue(), VQwDataHandler::PrintValue(), VQwDetectorArray::PrintValue(), VQwScaler_Channel::PrintValue(), QwEPICSEvent::PrintVariableList(), QwADC18_Channel::ProcessDataWord(), QwADC18_Channel::ProcessEvBuffer(), QwBeamMod::ProcessEvBuffer(), QwHelicity::ProcessEvBuffer(), QwADC18_Channel::ProcessEvent(), QwCombinedBCM< T >::ProcessEvent(), QwHelicity::ProcessEvent(), QwMollerADC_Channel::ProcessEvent(), QwVQWK_Channel::ProcessEvent(), VQwScaler_Channel::ProcessEvent(), VQwDetectorArray::ProcessEvent_2(), QwHelicity::ProcessEventInputMollerMode(), QwHelicity::ProcessEventInputRegisterMode(), QwHelicity::ProcessEventUserbitMode(), QwBlinder::ProcessOptions(), QwDatabase::ProcessOptions(), QwEventBuffer::ProcessOptions(), QwEventRing::ProcessOptions(), QwHelicity::ProcessOptions(), QwHelicityPattern::ProcessOptions(), QwHistogramHelper::ProcessOptions(), QwRootFile::ProcessOptions(), VQwDetectorArray::ProcessOptions(), MQwPublishable< U, T >::PublishByRequest(), VQwDataHandler::PublishByRequest(), VQwDetectorArray::PublishByRequest(), MQwPublishable< U, T >::PublishInternalValue(), QwBeamLine::PublishInternalValues(), VQwDataHandler::PublishInternalValues(), VQwDetectorArray::PublishInternalValues(), QwEventRing::push(), QwDataHandlerArray::push_back(), QwDataHandlerArray::push_back(), QwSubsystemArray::push_back(), QwSubsystemArray::push_back(), QwBlinder::QwBlinder(), QwCorrelator::QwCorrelator(), QwDatabase::QwDatabase(), QwDatabase::QwDatabase(), QwDataHandlerArray::QwDataHandlerArray(), QwDataHandlerArray::QwDataHandlerArray(), QwHelicityPattern::QwHelicityPattern(), QwParameterFile::QwParameterFile(), QwRootFile::QwRootFile(), QwRootTree::QwRootTree(), QwRootTree::QwRootTree(), QwScopedConnection::QwScopedConnection(), QwSubsystemArray::QwSubsystemArray(), VQwDetectorArray::RandomizeMollerEvent(), QwSubsystemArrayParity::Ratio(), QwParameterFile::ReadNextLine_Greedy(), VQwSubsystem::RegisterMarkerWord(), VQwSubsystem::RegisterROCNumber(), VQwSubsystem::RegisterSubbank(), QwBeamDetectorID::ReportInitErrors(), MQwCodaControlEvent::ReportRunSummary(), MQwPublishable_child< QwDataHandlerArray, VQwDataHandler >::RequestExternalPointer(), QwHelicity::ResetPredictor(), MQwPublishable< U, T >::ReturnInternalValue(), MQwPublishable< QwDataHandlerArray, VQwDataHandler >::ReturnInternalValue(), QwHelicity::RunPredictor(), QwDatabase::SetAccessLevel(), QwOptions::SetCommandLine(), QwOptions::SetConfigFile(), QwHelicity::SetHelicityBitPattern(), QwHelicity::SetHelicityDelay(), QwBlinder::SetIHWPPolarity(), QwBCM< T >::SetSingleEventCuts(), QwBPMCavity::SetSingleEventCuts(), QwBPMStripline< T >::SetSingleEventCuts(), QwClock< T >::SetSingleEventCuts(), QwCombinedPMT::SetSingleEventCuts(), QwEnergyCalculator::SetSingleEventCuts(), QwHaloMonitor::SetSingleEventCuts(), QwIntegrationPMT::SetSingleEventCuts(), QwLinearDiodeArray::SetSingleEventCuts(), QwQPD::SetSingleEventCuts(), VQwBPM::SetSingleEventCuts(), VQwBPM::SetSingleEventCuts(), VQwHardwareChannel::SetSingleEventCuts(), QwBlinder::SetTargetBlindability(), QwPromptSummary::SetupElementList(), QwBlinder::SetWienState(), QwParameterFile::SkipSection(), LinRegBevPeb::solve(), QwDatabase::StoreDBVersion(), Coda3EventDecoder::trigBankDecode(), Coda3EventDecoder::trigBankErrorHandler(), QwEventRing::Unwind(), QwBlinder::Update(), QwBlinder::Update(), QwRootFile::Update(), LRBCorrector::UpdateBurstCounter(), QwSubsystemArrayParity::UpdateErrorFlag(), QwOptions::Usage(), QwDatabase::ValidateConnection(), QwEventBuffer::VerifyCodaVersion(), QwOptions::Version(), QwCorrelator::WriteAliasFile(), QwEPICSEvent::WriteEPICSStringValues(), QwEventBuffer::WriteEvent(), QwBPMStripline< T >::WritePromptSummary(), VQwDataHandler::WritePromptSummary(), VQwDetectorArray::WritePromptSummary(), QwDatabase::~QwDatabase(), and QwRootFile::~QwRootFile().

+ Here is the caller graph for this function:

◆ flush()

std::ostream & QwLog::flush ( std::ostream & strm)
static

Flush the streams.

Flush the streams

Definition at line 317 of file QwLog.cc.

318{
319 if (gQwLog.fScreen) {
320 *(gQwLog.fScreen) << std::flush;
321 }
322 if (gQwLog.fFile) {
323 *(gQwLog.fFile) << std::flush;
324 }
325 return strm;
326}

References gQwLog.

Referenced by QwInterpolator< value_t, value_n >::ReadBinaryFile(), QwInterpolator< value_t, value_n >::ReadText(), QwInterpolator< value_t, value_n >::WriteBinaryFile(), and QwInterpolator< value_t, value_n >::WriteText().

+ Here is the caller graph for this function:

◆ GetLogLevel()

QwLogLevel QwLog::GetLogLevel ( ) const
inline

Get highest log level.

Definition at line 131 of file QwLog.h.

131 {
132 return std::max(fScreenThreshold, fFileThreshold);
133 };

References fFileThreshold, and fScreenThreshold.

◆ GetTime()

const char * QwLog::GetTime ( )
private

Get the local time.

Get the local time

Definition at line 330 of file QwLog.cc.

331{
332 time_t now = time(0);
333 if (now >= 0) {
334 struct tm *currentTime = localtime(&now);
335 strftime(fTimeString, 128, "%Y-%m-%d, %T", currentTime);
336 return fTimeString;
337 } else {
338 return "";
339 }
340}
char fTimeString[128]
Definition QwLog.h:172

References fTimeString.

Referenced by operator()().

+ Here is the caller graph for this function:

◆ InitLogFile()

void QwLog::InitLogFile ( const std::string name,
const std::ios_base::openmode mode = kAppend )

Initialize the log file with name 'name'.

Initialize the log file with name 'name'

Definition at line 155 of file QwLog.cc.

156{
157 if (fFile) {
158 delete fFile;
159 fFile = 0;
160 }
161
162 std::ios_base::openmode flags = std::ios::out | mode;
163 fFile = new std::ofstream(name.c_str(), flags);
165}

References fFile, fFileThreshold, and kMessage.

Referenced by ProcessOptions().

+ Here is the caller graph for this function:

◆ IsDebugFunction()

bool QwLog::IsDebugFunction ( const string func_sig)

Determine whether the function name matches a specified list of regular expressions.

Determine whether the function name matches a specified list of regular expressions

Definition at line 135 of file QwLog.cc.

136{
137 // If not in our cached list
138 if (fIsDebugFunction.find(func_sig) == fIsDebugFunction.end()) {
139 // Look through all regexes
140 fIsDebugFunction[func_sig] = false;
141 for (size_t i = 0; i < fDebugFunctionRegexString.size(); i++) {
142 // When we find a match, cache it and break out
143 std::regex regex(fDebugFunctionRegexString.at(i));
144 if (std::regex_match(func_sig, regex)) {
145 fIsDebugFunction[func_sig] = true;
146 break;
147 }
148 }
149 }
150 return fIsDebugFunction[func_sig];
151}
std::map< std::string, bool > fIsDebugFunction
List of regular expressions for functions that will have increased log level.
Definition QwLog.h:187
std::vector< std::string > fDebugFunctionRegexString
Definition QwLog.h:188

References fDebugFunctionRegexString, and fIsDebugFunction.

Referenced by operator()().

+ Here is the caller graph for this function:

◆ operator()()

QwLog & QwLog::operator() ( const QwLogLevel level,
const std::string func_sig = "<unknown>" )

Set the stream log level.

Set the stream log level

Definition at line 190 of file QwLog.cc.

193{
194 // Set the log level of this sink
195 fLogLevel = level;
196
197 // Override log level of this sink when in a debugged function
199
201 if (fScreenAtNewLine) {
202 // Put something at the beginning of a new line
203 switch (level) {
204 case kError:
205 if (fUseColor) {
206 *(fScreen) << QwColor(Qw::kRed);
207 fScreenInColor = true;
208 }
210 *(fScreen) << "Error (in " << func_sig << "): ";
211 else
212 *(fScreen) << "Error: ";
213 break;
214 case kWarning:
215 if (fUseColor) {
216 *(fScreen) << QwColor(Qw::kRed);
217 fScreenInColor = true;
218 }
220 *(fScreen) << "Warning (in " << func_sig << "): ";
221 else
222 *(fScreen) << "Warning: ";
223 if (fUseColor) {
224 *(fScreen) << QwColor(Qw::kNormal);
225 fScreenInColor = false;
226 }
227 break;
228 default:
229 fScreenInColor = false;
230 break;
231 }
232 }
233 fScreenAtNewLine = false;
234 }
235
236 if (fFile && fLogLevel <= fFileThreshold) {
237 if (fFileAtNewLine) {
238 *(fFile) << GetTime();
239 switch (level) {
240 case kError: *(fFile) << " EE"; break;
241 case kWarning: *(fFile) << " WW"; break;
242 case kMessage: *(fFile) << " MM"; break;
243 case kVerbose: *(fFile) << " VV"; break;
244 case kDebug: *(fFile) << " DD"; break;
245 default: *(fFile) << " "; break;
246 }
247 *(fFile) << " - ";
248 fFileAtNewLine = false;
249 }
250 }
251
252 return *this;
253}
@ kRed
Definition QwColor.h:77
const char * GetTime()
Get the local time.
Definition QwLog.cc:330
bool IsDebugFunction(const string func_name)
Determine whether the function name matches a specified list of regular expressions.
Definition QwLog.cc:135

References fFile, fFileAtNewLine, fFileThreshold, fLogLevel, fPrintFunctionSignature, fScreen, fScreenAtNewLine, fScreenInColor, fScreenThreshold, fUseColor, GetTime(), IsDebugFunction(), kAlways, kDebug, kError, kMessage, Qw::kNormal, Qw::kRed, kVerbose, kWarning, and QwLog().

+ Here is the call graph for this function:

◆ operator<<() [1/2]

template<class T>
QwLog & QwLog::operator<< ( const T & t)
inline

Stream an object to the output stream.

Definition at line 142 of file QwLog.h.

142 {
144 *(fScreen) << t;
145 }
146 if (fFile && fLogLevel <= fFileThreshold) {
147 *(fFile) << t;
148 }
149 return *this;
150 }

References fFile, fFileThreshold, fLogLevel, fScreen, fScreenThreshold, and QwLog().

+ Here is the call graph for this function:

◆ operator<<() [2/2]

QwLog & QwLog::operator<< ( std::ostream &(* manip )(std::ostream &))

Pass the ios_base manipulators.

Definition at line 278 of file QwLog.cc.

279{
281 *(fScreen) << manip;
282 }
283
284// The following solution leads to double calls to QwLog::endl
285// if (fScreen && fLogLevel <= fScreenThreshold) {
286// *(fScreen) << manip;
287// }
288// if (fFile && fLogLevel <= fFileThreshold) {
289// *(fFile) << manip;
290// }
291
292 return *this;
293}

References fFileThreshold, fLogLevel, fScreen, fScreenThreshold, and QwLog().

+ Here is the call graph for this function:

◆ ProcessOptions()

void QwLog::ProcessOptions ( QwOptions * options)

Process class options for QwOptions.

Process configuration options for logging class using QwOptions functionality.

Note: this uses a pointer as opposed to a reference, because as indicated above the QwLog class cannot depend on the QwOptions class. When using a pointer we only need a forward declaration and we do not need to include the header file QwOptions.h.

Parameters
optionsOptions object

Definition at line 106 of file QwLog.cc.

107{
108 // Initialize log file
109 if (options->HasValue("QwLog.logfile"))
110 InitLogFile(options->GetValue<std::string>("QwLog.logfile"));
111
112 // Set the logging thresholds
113 SetFileThreshold(options->GetValue<int>("QwLog.loglevel-file"));
114 SetScreenThreshold(options->GetValue<int>("QwLog.loglevel-screen"));
115
116 // Set color flag
117 SetScreenColor(options->GetValue<bool>("QwLog.color"));
118
119 // Set the flags for function name and signature printing
120 fPrintFunctionSignature = options->GetValue<bool>("QwLog.print-signature");
121
122 // Set the list of regular expressions for functions to debug
123 fDebugFunctionRegexString = options->GetValueVector<std::string>("QwLog.debug-function");
124 if (fDebugFunctionRegexString.size() > 0)
125 std::cout << "Debug regex list:" << std::endl;
126 for (size_t i = 0; i < fDebugFunctionRegexString.size(); i++) {
127 std::cout << fDebugFunctionRegexString.back() << std::endl;
128 }
129}
void SetFileThreshold(int thr)
Set the file log level.
Definition QwLog.cc:183
void SetScreenThreshold(int thr)
Set the screen log level.
Definition QwLog.cc:176
void InitLogFile(const std::string name, const std::ios_base::openmode mode=kAppend)
Initialize the log file with name 'name'.
Definition QwLog.cc:155
void SetScreenColor(bool flag)
Set the screen color mode.
Definition QwLog.cc:169
std::vector< T > GetValueVector(const std::string &key)
Get a list of templated values.
Definition QwOptions.h:249
T GetValue(const std::string &key)
Get a templated value.
Definition QwOptions.h:236
bool HasValue(const std::string &key)
Has this key been defined.
Definition QwOptions.h:229

References fDebugFunctionRegexString, fPrintFunctionSignature, QwOptions::GetValue(), QwOptions::GetValueVector(), QwOptions::HasValue(), InitLogFile(), SetFileThreshold(), SetScreenColor(), and SetScreenThreshold().

+ Here is the call graph for this function:

◆ SetFileThreshold()

void QwLog::SetFileThreshold ( int thr)

Set the file log level.

Set the file log level

Definition at line 183 of file QwLog.cc.

184{
186}
QwLogLevel
Loglevels.
Definition QwLog.h:88

References fFileThreshold.

Referenced by ProcessOptions().

+ Here is the caller graph for this function:

◆ SetScreenColor()

void QwLog::SetScreenColor ( bool flag)

Set the screen color mode.

Set the screen color mode

Definition at line 169 of file QwLog.cc.

170{
171 fUseColor = flag;
172}

References fUseColor.

Referenced by ProcessOptions().

+ Here is the caller graph for this function:

◆ SetScreenThreshold()

void QwLog::SetScreenThreshold ( int thr)

Set the screen log level.

Set the screen log level

Definition at line 176 of file QwLog.cc.

177{
179}

References fScreenThreshold.

Referenced by ProcessOptions().

+ Here is the caller graph for this function:

Field Documentation

◆ fDebugFunctionRegexString

std::vector<std::string> QwLog::fDebugFunctionRegexString
private

Definition at line 188 of file QwLog.h.

Referenced by IsDebugFunction(), and ProcessOptions().

◆ fFile

std::ostream* QwLog::fFile
private

Definition at line 179 of file QwLog.h.

Referenced by InitLogFile(), operator()(), operator<<(), QwLog(), and ~QwLog().

◆ fFileAtNewLine

bool QwLog::fFileAtNewLine = true
staticprivate

Flags only relevant for current line, but static for use in static function.

Definition at line 194 of file QwLog.h.

Referenced by endl(), and operator()().

◆ fFileThreshold

QwLogLevel QwLog::fFileThreshold
private

File thresholds and stream.

Definition at line 178 of file QwLog.h.

Referenced by GetLogLevel(), InitLogFile(), operator()(), operator<<(), operator<<(), QwLog(), and SetFileThreshold().

◆ fIsDebugFunction

std::map<std::string,bool> QwLog::fIsDebugFunction
private

List of regular expressions for functions that will have increased log level.

Definition at line 187 of file QwLog.h.

Referenced by IsDebugFunction().

◆ fLogLevel

QwLogLevel QwLog::fLogLevel
private

Log level of this stream.

Definition at line 181 of file QwLog.h.

Referenced by operator()(), operator<<(), operator<<(), and QwLog().

◆ fPrintFunctionSignature

bool QwLog::fPrintFunctionSignature
private

Flag to print function signature on warning or error.

Definition at line 184 of file QwLog.h.

Referenced by operator()(), ProcessOptions(), and QwLog().

◆ fScreen

std::ostream* QwLog::fScreen
private

Definition at line 176 of file QwLog.h.

Referenced by operator()(), operator<<(), operator<<(), and QwLog().

◆ fScreenAtNewLine

bool QwLog::fScreenAtNewLine = true
staticprivate

Definition at line 196 of file QwLog.h.

Referenced by endl(), and operator()().

◆ fScreenInColor

bool QwLog::fScreenInColor = false
staticprivate

Definition at line 195 of file QwLog.h.

Referenced by endl(), and operator()().

◆ fScreenThreshold

QwLogLevel QwLog::fScreenThreshold
private

Screen thresholds and stream.

Definition at line 175 of file QwLog.h.

Referenced by GetLogLevel(), operator()(), operator<<(), operator<<(), QwLog(), and SetScreenThreshold().

◆ fTimeString

char QwLog::fTimeString[128]
private

Definition at line 172 of file QwLog.h.

Referenced by GetTime().

◆ fUseColor

bool QwLog::fUseColor
private

Flag to disable color.

Definition at line 191 of file QwLog.h.

Referenced by operator()(), QwLog(), and SetScreenColor().

◆ kAppend

const std::ios_base::openmode QwLog::kAppend = std::ios::app
static

Definition at line 99 of file QwLog.h.

◆ kTruncate

const std::ios_base::openmode QwLog::kTruncate = std::ios::trunc
static

Log file open modes.

Definition at line 98 of file QwLog.h.


The documentation for this class was generated from the following files: