QwAnalysis
QwLog Class Reference

A logfile class. More...

#include <QwLog.h>

Inherits std::ostream.

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

Static Public Member Functions

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

Static Public Attributes

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

Private Member Functions

const char * GetTime ()
 Get the local time. More...
 

Private Attributes

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

Static Private Attributes

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

Detailed Description

A logfile class.

This class should not be used directly. Instead one can write text to the screen or a log file via the predefined log drains QwError, QwWarning, QwMessage, QwVerbose and QwDebug. A special log drain QwOut will always be printed and is reserved for output explicitly requested by the user.

An example could be:

 QwMessage << "Hello World !!!" << QwLog::endl;

Definition at line 78 of file QwLog.h.

Member Enumeration Documentation

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 93 of file QwLog.h.

93  {
94  kAlways = -1, /*!< Explicit output */
95  kError = 0, /*!< Error loglevel */
96  kWarning = 1, /*!< Warning loglevel */
97  kMessage = 2, /*!< Message loglevel */
98  kVerbose = 3, /*!< Verbose loglevel */
99  kDebug = 4 /*!< Debug loglevel */
100  };

Constructor & Destructor Documentation

QwLog::QwLog ( )

The constructor.

The constructor initializes the screen stream and resets the file stream

Definition at line 35 of file QwLog.cc.

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

36 : std::ostream(std::cout.rdbuf())
37 {
39  fScreen = &std::cout;
40 
42  fFile = 0;
43 
45 
46  fUseColor = true;
47 
49 }
QwLogLevel fFileThreshold
File thresholds and stream.
Definition: QwLog.h:177
QwLogLevel fScreenThreshold
Screen thresholds and stream.
Definition: QwLog.h:174
std::ostream * fScreen
Definition: QwLog.h:175
bool fPrintFunctionSignature
Flag to print function signature on warning or error.
Definition: QwLog.h:183
QwLogLevel fLogLevel
Log level of this stream.
Definition: QwLog.h:180
std::ostream * fFile
Definition: QwLog.h:178
bool fUseColor
Flag to disable color.
Definition: QwLog.h:190
QwLog::~QwLog ( )
virtual

The destructor.

The destructor destroys the log file, if it was present

Definition at line 53 of file QwLog.cc.

References fFile.

54 {
55  if (fFile) {
56  delete fFile;
57  fFile = 0;
58  }
59 }
std::ostream * fFile
Definition: QwLog.h:178

Member Function Documentation

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 73 of file QwLog.cc.

References QwOptions::AddOptions(), default_bool_value, and kMessage.

Referenced by QwOptions::DefineOptions().

74 {
75  // Define the logging options
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",
80  po::value<string>(),
81  "log file");
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",
89  po::value<bool>()->default_bool_value(false),
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");
94 }
#define default_bool_value(b)
Definition: QwOptions.h:51
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:164

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

End of the line.

End of the line

Definition at line 299 of file QwLog.cc.

References fFile, fFileAtNewLine, fFileThreshold, fLogLevel, fScreen, fScreenAtNewLine, fScreenInColor, fScreenThreshold, and Qw::kNormal.

Referenced by QwTrackingTree::_inittree(), QwTrackingTree::_readtree(), QwTrackingTreeSearch::_SearchTreeLines(), QwSubsystemArrayParity::AccumulateAllRunningSum(), QwSubsystemArrayParity::AccumulateRunningSum(), QwVQWK_Channel::AccumulateRunningSum(), VQwScaler_Channel::AccumulateRunningSum(), QwOptions::AddConfigFile(), QwEvent::AddHit(), QwSIS3320_Channel::AddLogicalAccumulator(), QwDBInterface::AddThisEntryToList(), QwErrDBInterface::AddThisEntryToList(), QwBeamMod::AnalyzeOpticsPlots(), QwVQWK_Channel::ApplyHWChecks(), QwTreeEventBuffer::AssignCrossSection(), QwSubsystemArray::AtEndOfEventLoop(), VQwSubsystem::AtEndOfEventLoop(), QwSubsystemArrayParity::Blind(), QwMatrixLookup::Bridge(), QwRayTracer::Bridge(), QwHelicity::BuildHelicityBitPattern(), QwHelicityPattern::CalculateAsymmetry(), QwCombinedBPM< T >::CalculateFixedParameter(), QwEvent::CalculateKinematics(), QwSubsystemArray::CanContain(), QwBlinder::CheckBlindability(), QwF1TDContainer::CheckDataIntegrity(), QwBlinder::CheckTestValues(), VQwCloneable< VQwDataElement >::Clone(), QwEventBuffer::CloseStream(), QwEventBuffer::CloseThisSegment(), QwHelicity::CollectRandBits24(), QwHelicity::CollectRandBits30(), QwScanner::Compare(), QwDatabase::Connect(), QwRegression::ConnectChannels(), QwTrackingTree::consistent(), QwEnergyCalculator::ConstructBranch(), QwHaloMonitor::ConstructBranch(), QwIntegratedRasterChannel< T >::ConstructBranch(), QwClock< T >::ConstructBranch(), QwCombinedPMT::ConstructBranch(), QwQPD::ConstructBranch(), QwBPMCavity::ConstructBranch(), QwLinearDiodeArray::ConstructBranch(), QwCombinedBPM< T >::ConstructBranch(), QwBPMStripline< T >::ConstructBranch(), QwIntegrationPMT::ConstructBranch(), QwBCM< T >::ConstructBranch(), QwSubsystemArray::ConstructBranch(), QwRootTree::ConstructBranchAndVector(), QwEPICSEvent::ConstructBranchAndVector(), QwVQWK_Channel::ConstructBranchAndVector(), QwHelicity::ConstructHistograms(), QwRootFile::ConstructHistograms(), QwRootTree::ConstructNewTree(), VQwClock::Create(), VQwBCM::Create(), VQwBCM::CreateCombo(), VQwBPM::CreateCombo(), QwTreeEventBuffer::CreateHitList(), QwTreeEventBuffer::CreateHitRegion1(), QwTreeEventBuffer::CreateHitRegion2(), QwTreeEventBuffer::CreateHitRegion3(), QwTreeEventBuffer::CreatePartialTracks(), VQwBPM::CreateStripline(), QwEventBuffer::DataFileIsSegmented(), QwSubsystemArrayParity::DeaccumulateRunningSum(), QwEventBuffer::DecodeSubbankHeader(), QwEPICSEvent::DetermineIHWPPolarity(), QwDBInterface::DetermineMeasurementTypeID(), QwPartialTrack::DeterminePositionInDetector(), QwPartialTrack::DeterminePositionInTarget(), QwHelicity::EncodeEventData(), QwMainCerenkovDetector::ExchangeProcessedData(), QwBeamMod::ExchangeProcessedData(), QwLumi::ExchangeProcessedData(), QwRootTree::Fill(), QwEPICSEvent::FillDB(), QwRegression::FillDB(), QwBlinder::FillDB(), QwMainCerenkovDetector::FillDB(), QwBeamLine::FillDB(), QwIntegratedRaster::FillDB(), QwLumi::FillDB(), QwBeamMod::FillDB_MPS(), QwEventBuffer::FillEPICSData(), QwBlinder::FillErrDB(), QwMainCerenkovDetector::FillErrDB(), QwBeamLine::FillErrDB(), QwIntegratedRaster::FillErrDB(), QwLumi::FillErrDB(), QwDriftChamberHDC::FillHistograms(), QwDriftChamberVDC::FillHistograms(), QwHelicity::FillHistograms(), QwParityDB::FillParameterFiles(), QwEPICSEvent::FillSlowControlsData(), QwEPICSEvent::FillSlowControlsSettings(), QwEPICSEvent::FillSlowControlsStrigs(), QwEventBuffer::FillSubsystemConfigurationData(), QwRootTree::FillTreeBranches(), QwSIS3320_Accumulator::FillTreeVector(), QwEPICSEvent::FillTreeVector(), VQwScaler_Channel::FillTreeVector(), QwBridgingTrackFilter::Filter(), QwParameterFile::FindFile(), QwParityDB::GetAnalysisID(), VQwScaler_Channel::GetBufferOffset(), QwVQWK_Channel::GetBufferOffset(), QwPartialTrack::GetChiWeight(), QwTreeLine::GetChiWeight(), QwMainCerenkovDetector::GetCombinedPMT(), QwLumi::GetCombinedPMT(), QwMagneticField::GetCylindricalFieldValue(), QwDetectorInfo::GetElementEfficiency(), QwTreeEventBuffer::GetEntry(), getenv_safe(), QwParityDB::GetErrorCodeID(), VQwFactory< VQwDataElement >::GetFactory(), QwMagneticField::GetFieldValue(), QwHistogramHelper::GetHistParamsFromFile(), QwHistogramHelper::GetHistParamsFromLine(), QwHistogramHelper::GetHistParamsFromList(), QwEvent::GetHitContainer(), QwMainCerenkovDetector::GetIntegrationPMT(), QwParityDB::GetLumiDetectorID(), QwParityDB::GetMainDetectorID(), QwParityDB::GetMeasurementID(), QwParityDB::GetMonitorID(), QwTreeEventBuffer::GetNextEvent(), QwEventBuffer::GetNextEvent(), QwEventBuffer::GetNextEventRange(), QwEventBuffer::GetNextRunRange(), VQwSubsystem::GetParent(), QwHelicity::GetRandbit24(), QwHelicity::GetRandbit30(), QwHelicity::GetRandomSeed(), QwParityDB::GetRunID(), QwParityDB::GetRunletID(), QwParityDB::GetSlowControlDetectorID(), QwOptions::GetValue(), QwParameterFile::HasValue(), QwBlinder::InitBlinders(), Uv2xy::InitializeRotationMatrices(), QwBlinder::InitTestValues(), QwTrackingTree::inittree(), QwTrackingWorker::InitTree(), QwHelicity::IsGoodEventNumber(), QwHelicity::IsGoodHelicity(), QwHelicity::IsGoodPatternNumber(), QwHelicity::IsGoodPhaseNumber(), QwRegression::LinearRegression(), QwOptions::ListConfigFiles(), QwTreeEventBuffer::ListCrossSections(), QwSubsystemArray::ListPublishedValues(), VQwFactory< VQwDataElement >::ListRegisteredTypes(), QwEvent::LoadBeamProperty(), QwScaler::LoadChannelMap(), QwEPICSEvent::LoadChannelMap(), QwRegression::LoadChannelMap(), QwHelicity::LoadChannelMap(), QwComptonPhotonDetector::LoadChannelMap(), QwBeamLine::LoadChannelMap(), QwMainCerenkovDetector::LoadChannelMap(), QwIntegratedRaster::LoadChannelMap(), QwBeamMod::LoadChannelMap(), QwLumi::LoadChannelMap(), QwVQWK_Channel::LoadChannelParameters(), QwDetectorInfo::LoadCrosstalkDefinition(), VQwSubsystemTracking::LoadCrosstalkDefinition(), QwBeamLine::LoadEventCuts(), QwMainCerenkovDetector::LoadEventCuts(), QwIntegratedRaster::LoadEventCuts(), QwBeamMod::LoadEventCuts(), QwLumi::LoadEventCuts(), QwHelicityPattern::LoadEventData(), QwBeamLine::LoadGeometryDefinition(), VQwSubsystemTracking::LoadGeometryDefinition(), QwHistogramHelper::LoadHistParamsFromFile(), QwScaler::LoadInputParameters(), QwComptonPhotonDetector::LoadInputParameters(), QwSubsystemArray::LoadSubsystemsFromParameterFile(), QwMatrixLookup::LoadTrajMatrix(), QwHistogramHelper::LoadTreeParamsFromFile(), main(), QwTrackingTree::marklin(), QwHistogramHelper::MatchDeviceParamsFromList(), QwTrackingTreeMatch::MatchRegion3(), QwHistogramHelper::MatchVQWKElementFromList(), QwTrackingTree::nodeexists(), QwEventBuffer::OpenDataFile(), QwTreeEventBuffer::OpenFile(), QwParameterFile::OpenFile(), QwEventBuffer::OpenNextSegment(), QwEventBuffer::OpenNextStream(), StoreMonitorID::operator()(), StoreMainDetectorID::operator()(), StoreLumiDetectorID::operator()(), StoreMeasurementID::operator()(), StoreSlowControlDetectorID::operator()(), StoreErrorCodeID::operator()(), QwScanner::operator+=(), QwSubsystemArrayParity::operator+=(), QwHelicity::operator+=(), QwScanner::operator-=(), VQwScaler_Channel::operator/=(), QwVQWK_Channel::operator/=(), QwScanner::operator=(), QwSubsystemArrayParity::operator=(), QwOptions::ParseCommandLine(), QwOptions::ParseConfigFile(), QwOptions::ParseEnvironment(), QwParameterFile::ParseIntRange(), QwEventRing::pop(), QwWord::Print(), QwTracking::shortnode::Print(), QwTracking::shorttree::Print(), QwPartialTrack::Print(), QwTracking::treenode::Print(), QwHelicity::Print(), QwBeamMod::Print(), QwGeometry::Print(), QwHelicityPattern::Print(), QwRootTree::Print(), VQwTrackingElementContainer< T >::Print(), QwDetectorInfo::Print(), QwModChannelID::Print(), QwF1TDContainer::Print(), QwEvent::Print(), QwHelicityPattern::PrintBurstAverage(), QwF1TDC::PrintChannelErrorCounter(), VQwSubsystem::PrintDetectorMaps(), QwRootFile::PrintDirs(), QwF1TDC::PrintErrorCounter(), QwVQWK_Channel::PrintErrorCounterHead(), QwHelicity::PrintErrorCounters(), QwBeamLine::PrintErrorCounters(), QwMainCerenkovDetector::PrintErrorCounters(), QwIntegratedRaster::PrintErrorCounters(), QwLumi::PrintErrorCounters(), VQwScaler_Channel::PrintErrorCounters(), QwVQWK_Channel::PrintErrorCounters(), QwVQWK_Channel::PrintErrorCounterTail(), QwBlinder::PrintFinalValues(), QwTrackingTree::PrintHashTable(), QwHistogramHelper::PrintHistParams(), MQwF1TDC::PrintHitFIFOStatus(), QwWord::PrintID(), PrintInfo(), QwScaler::PrintInfo(), QwComptonPhotonDetector::PrintInfo(), QwSIS3320_Channel::PrintInfo(), QwIntegratedRaster::PrintInfo(), QwLumi::PrintInfo(), VQwScaler_Channel::PrintInfo(), QwTrackingTreeRegion::PrintNodes(), MQwF1TDC::PrintOutputFIFOStatus(), QwTrack::PrintPartialTracks(), MQwF1TDC::PrintResolutionLockStatus(), QwHelicityPattern::PrintRunningAverage(), QwHelicityPattern::PrintRunningBurstAverage(), QwEventBuffer::PrintRunTimes(), QwTreeEventBuffer::PrintStatInfo(), QwDBInterface::PrintStatus(), QwErrDBInterface::PrintStatus(), QwF1TDC::PrintTotalErrorCounter(), QwTrackingTree::PrintTree(), QwTrackingTreeRegion::PrintTrees(), QwRootFile::PrintTrees(), QwPartialTrack::PrintValid(), QwPMT_Channel::PrintValue(), QwRegression::PrintValue(), QwBeamLine::PrintValue(), QwSIS3320_Channel::PrintValue(), QwIntegratedRaster::PrintValue(), QwLumi::PrintValue(), VQwScaler_Channel::PrintValue(), QwComptonElectronDetector::PrintValue(), QwMainCerenkovDetector::PrintValue(), QwVQWK_Channel::PrintValue(), QwEPICSEvent::PrintVariableList(), QwSIS3320_Accumulator::ProcessEvBuffer(), QwComptonPhotonDetector::ProcessEvBuffer(), QwHelicity::ProcessEvBuffer(), QwSIS3320_Channel::ProcessEvBuffer(), QwSIS3320_Samples::ProcessEvBuffer(), QwBeamMod::ProcessEvBuffer(), QwComptonElectronDetector::ProcessEvBuffer(), QwCombinedBCM< T >::ProcessEvent(), QwHelicity::ProcessEvent(), VQwScaler_Channel::ProcessEvent(), QwTrackingWorker::ProcessEvent(), QwVQWK_Channel::ProcessEvent(), QwMainCerenkovDetector::ProcessEvent_2(), QwLumi::ProcessEvent_2(), QwHelicity::ProcessEventInputMollerMode(), QwHelicity::ProcessEventInputRegisterMode(), QwHelicity::ProcessEventUserbitMode(), QwHistogramHelper::ProcessOptions(), QwHelicityPattern::ProcessOptions(), QwHelicity::ProcessOptions(), QwDatabase::ProcessOptions(), QwEventBuffer::ProcessOptions(), QwMainCerenkovDetector::ProcessOptions(), QwLumi::ProcessOptions(), QwBlinder::ProcessOptions(), QwRootFile::ProcessOptions(), QwLumi::PublishByRequest(), QwSubsystemArray::PublishByRequest(), VQwSubsystem::PublishInternalValue(), QwSubsystemArray::PublishInternalValue(), QwBeamLine::PublishInternalValues(), QwMainCerenkovDetector::PublishInternalValues(), QwEventRing::push(), QwSubsystemArray::push_back(), QwDatabase::QwDatabase(), QwEventBuffer::QwEventBuffer(), QwHelicityPattern::QwHelicityPattern(), QwMagneticField::QwMagneticField(), QwParameterFile::QwParameterFile(), QwParityDB::QwParityDB(), QwRegressionSubsystem::QwRegressionSubsystem(), QwRootFile::QwRootFile(), QwRootTree::QwRootTree(), QwSubsystemArray::QwSubsystemArray(), QwTrackingWorker::QwTrackingWorker(), QwTrackingTreeCombine::r2_PartialTrackFit(), QwTrackingTreeCombine::r3_PartialTrackFit(), QwSubsystemArrayParity::Ratio(), QwMagneticField::ReadFieldMap(), QwMagneticField::ReadFieldMapFile(), QwMagneticField::ReadFieldMapStream(), QwMagneticField::ReadFieldMapZip(), QwBlinder::ReadSeed(), QwTrackingTree::readtree(), VQwSubsystem::RegisterROCNumber(), VQwSubsystem::RegisterSubbank(), QwBeamDetectorID::ReportInitErrors(), MQwCodaControlEvent::ReportRunSummary(), QwHelicity::ResetPredictor(), QwSubsystemArray::ReturnInternalValue(), QwHelicity::RunPredictor(), QwTrackingTreeSearch::SearchTreeLines(), QwDatabase::SetAccessLevel(), QwParityDB::SetAnalysisID(), Uv2xy::SetAngleUVinXY(), QwOptions::SetCommandLine(), QwDetectorInfo::SetElementEfficiency(), QwHelicity::SetHelicityBitPattern(), QwHelicity::SetHelicityDelay(), QwBlinder::SetIHWPPolarity(), QwTracking::shortnode::SetNext(), QwTracking::nodenode::SetNext(), QwTracking::treenode::SetNext(), Uv2xy::SetOffset(), QwParityDB::SetRunID(), QwParityDB::SetRunletID(), QwParityDB::SetRunNumber(), QwEnergyCalculator::SetSingleEventCuts(), QwCombinedPMT::SetSingleEventCuts(), QwClock< T >::SetSingleEventCuts(), QwIntegratedRasterChannel< T >::SetSingleEventCuts(), VQwBPM::SetSingleEventCuts(), VQwHardwareChannel::SetSingleEventCuts(), QwBCM< T >::SetSingleEventCuts(), QwIntegrationPMT::SetSingleEventCuts(), QwF1TDContainer::SetSystemName(), QwBlinder::SetTargetBlindability(), QwTracking::nodenode::SetTree(), QwParityDB::SetupOneRun(), QwBlinder::SetWienState(), Uv2xy::SetWireSpacing(), QwComptonPhotonDetector::SingleEventCuts(), QwParameterFile::SkipSection(), sql_create_6(), QwDatabase::StoreDBVersion(), QwParityDB::StoreErrorCodeIDs(), QwParityDB::StoreLumiDetectorIDs(), QwParityDB::StoreMainDetectorIDs(), QwParityDB::StoreMeasurementIDs(), QwParityDB::StoreMonitorIDs(), QwParityDB::StoreSlowControlDetectorIDs(), QwTrackingTreeCombine::TcTreeLineCombine(), QwMagneticField::TestFieldMap(), QwTrackingTreeCombine::TlCheckForX(), QwTrackingTreeCombine::TlMatchHits(), QwTrackingTreeCombine::TlTreeCombine(), QwTrackingTreeCombine::TlTreeLineSort(), QwBlinder::Update(), QwSubsystemArrayParity::UpdateErrorFlag(), QwOptions::Usage(), QwDatabase::ValidateConnection(), QwOptions::Version(), QwEPICSEvent::WriteEPICSStringValues(), QwEventBuffer::WriteEvent(), QwBlinder::WriteFinalValuesToDB(), QwBPMStripline< T >::WritePromptSummary(), QwIntegratedRaster::WritePromptSummary(), QwLumi::WritePromptSummary(), QwMainCerenkovDetector::WritePromptSummary(), QwMatrixLookup::WriteTrajMatrix(), QwTrackingTree::writetree(), QwDatabase::~QwDatabase(), QwParityDB::~QwParityDB(), QwRootFile::~QwRootFile(), QwTrackingTree::~QwTrackingTree(), QwTrackingTreeRegion::~QwTrackingTreeRegion(), and QwTrackingWorker::~QwTrackingWorker().

300 {
302  if (fScreenInColor)
303  *(gQwLog.fScreen) << QwColor(Qw::kNormal) << std::endl;
304  else
305  *(gQwLog.fScreen) << std::endl;
306  fScreenAtNewLine = true;
307  fScreenInColor = false;
308  }
310  *(gQwLog.fFile) << std::endl;
311  fFileAtNewLine = true;
312  }
313 
314  return strm;
315 }
QwLogLevel fFileThreshold
File thresholds and stream.
Definition: QwLog.h:177
static bool fScreenAtNewLine
Definition: QwLog.h:195
static bool fFileAtNewLine
Flags only relevant for current line, but static for use in static function.
Definition: QwLog.h:193
QwLogLevel fScreenThreshold
Screen thresholds and stream.
Definition: QwLog.h:174
std::ostream * fScreen
Definition: QwLog.h:175
QwLogLevel fLogLevel
Log level of this stream.
Definition: QwLog.h:180
std::ostream * fFile
Definition: QwLog.h:178
A color changing class for the output stream.
Definition: QwColor.h:98
static bool fScreenInColor
Definition: QwLog.h:194
QwLog gQwLog
Definition: QwLog.cc:22
std::ostream & QwLog::flush ( std::ostream &  strm)
static

Flush the streams.

Flush the streams

Definition at line 319 of file QwLog.cc.

References fFile, and fScreen.

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

320 {
321  if (gQwLog.fScreen) {
322  *(gQwLog.fScreen) << std::flush;
323  }
324  if (gQwLog.fFile) {
325  *(gQwLog.fFile) << std::flush;
326  }
327  return strm;
328 }
std::ostream * fScreen
Definition: QwLog.h:175
std::ostream * fFile
Definition: QwLog.h:178
QwLog gQwLog
Definition: QwLog.cc:22

+ Here is the caller graph for this function:

const char * QwLog::GetTime ( )
private

Get the local time.

Get the local time

Definition at line 332 of file QwLog.cc.

References fTimeString.

Referenced by operator()().

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

+ Here is the caller graph for this function:

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 157 of file QwLog.cc.

References fFile, fFileThreshold, and kMessage.

Referenced by main(), and ProcessOptions().

158 {
159  if (fFile) {
160  delete fFile;
161  fFile = 0;
162  }
163 
164  std::ios_base::openmode flags = std::ios::out | mode;
165  fFile = new std::ofstream(name.c_str(), flags);
167 }
QwLogLevel fFileThreshold
File thresholds and stream.
Definition: QwLog.h:177
std::ostream * fFile
Definition: QwLog.h:178

+ Here is the caller graph for this function:

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 137 of file QwLog.cc.

References fDebugFunctionRegexString, fIsDebugFunction, and regex.

Referenced by operator()().

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

+ Here is the caller graph for this function:

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 192 of file QwLog.cc.

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

195 {
196  // Set the log level of this sink
197  fLogLevel = level;
198 
199  // Override log level of this sink when in a debugged function
200  if (IsDebugFunction(func_sig)) fLogLevel = QwLog::kAlways;
201 
202  if (fScreen && fLogLevel <= fScreenThreshold) {
203  if (fScreenAtNewLine) {
204  // Put something at the beginning of a new line
205  switch (level) {
206  case kError:
207  if (fUseColor) {
208  *(fScreen) << QwColor(Qw::kRed);
209  fScreenInColor = true;
210  }
212  *(fScreen) << "Error (in " << func_sig << "): ";
213  else
214  *(fScreen) << "Error: ";
215  break;
216  case kWarning:
217  if (fUseColor) {
218  *(fScreen) << QwColor(Qw::kRed);
219  fScreenInColor = true;
220  }
222  *(fScreen) << "Warning (in " << func_sig << "): ";
223  else
224  *(fScreen) << "Warning: ";
225  if (fUseColor) {
226  *(fScreen) << QwColor(Qw::kNormal);
227  fScreenInColor = false;
228  }
229  break;
230  default:
231  fScreenInColor = false;
232  break;
233  }
234  }
235  fScreenAtNewLine = false;
236  }
237 
238  if (fFile && fLogLevel <= fFileThreshold) {
239  if (fFileAtNewLine) {
240  *(fFile) << GetTime();
241  switch (level) {
242  case kError: *(fFile) << " EE"; break;
243  case kWarning: *(fFile) << " WW"; break;
244  case kMessage: *(fFile) << " MM"; break;
245  case kVerbose: *(fFile) << " VV"; break;
246  case kDebug: *(fFile) << " DD"; break;
247  default: *(fFile) << " "; break;
248  }
249  *(fFile) << " - ";
250  fFileAtNewLine = false;
251  }
252  }
253 
254  return *this;
255 }
QwLogLevel fFileThreshold
File thresholds and stream.
Definition: QwLog.h:177
static bool fScreenAtNewLine
Definition: QwLog.h:195
static bool fFileAtNewLine
Flags only relevant for current line, but static for use in static function.
Definition: QwLog.h:193
QwLogLevel fScreenThreshold
Screen thresholds and stream.
Definition: QwLog.h:174
std::ostream * fScreen
Definition: QwLog.h:175
const char * GetTime()
Get the local time.
Definition: QwLog.cc:332
bool fPrintFunctionSignature
Flag to print function signature on warning or error.
Definition: QwLog.h:183
QwLogLevel fLogLevel
Log level of this stream.
Definition: QwLog.h:180
std::ostream * fFile
Definition: QwLog.h:178
A color changing class for the output stream.
Definition: QwColor.h:98
bool fUseColor
Flag to disable color.
Definition: QwLog.h:190
static bool fScreenInColor
Definition: QwLog.h:194
bool IsDebugFunction(const string func_name)
Determine whether the function name matches a specified list of regular expressions.
Definition: QwLog.cc:137

+ Here is the call graph for this function:

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

Stream an object to the output stream.

Definition at line 141 of file QwLog.h.

References fFile, fFileThreshold, fLogLevel, fScreen, and fScreenThreshold.

141  {
142  if (fScreen && fLogLevel <= fScreenThreshold) {
143  *(fScreen) << t;
144  }
145  if (fFile && fLogLevel <= fFileThreshold) {
146  *(fFile) << t;
147  }
148  return *this;
149  }
QwLogLevel fFileThreshold
File thresholds and stream.
Definition: QwLog.h:177
QwLogLevel fScreenThreshold
Screen thresholds and stream.
Definition: QwLog.h:174
std::ostream * fScreen
Definition: QwLog.h:175
QwLogLevel fLogLevel
Log level of this stream.
Definition: QwLog.h:180
std::ostream * fFile
Definition: QwLog.h:178
QwLog & QwLog::operator<< ( std::ostream &(*)(std::ostream &)  manip)

Pass the ios_base manipulators.

Definition at line 280 of file QwLog.cc.

References fFileThreshold, fLogLevel, fScreen, and fScreenThreshold.

281 {
283  *(fScreen) << manip;
284  }
285 
286 // The following solution leads to double calls to QwLog::endl
287 // if (fScreen && fLogLevel <= fScreenThreshold) {
288 // *(fScreen) << manip;
289 // }
290 // if (fFile && fLogLevel <= fFileThreshold) {
291 // *(fFile) << manip;
292 // }
293 
294  return *this;
295 }
QwLogLevel fFileThreshold
File thresholds and stream.
Definition: QwLog.h:177
QwLogLevel fScreenThreshold
Screen thresholds and stream.
Definition: QwLog.h:174
std::ostream * fScreen
Definition: QwLog.h:175
QwLogLevel fLogLevel
Log level of this stream.
Definition: QwLog.h:180
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 108 of file QwLog.cc.

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

Referenced by main().

109 {
110  // Initialize log file
111  if (options->HasValue("QwLog.logfile"))
112  InitLogFile(options->GetValue<std::string>("QwLog.logfile"));
113 
114  // Set the logging thresholds
115  SetFileThreshold(options->GetValue<int>("QwLog.loglevel-file"));
116  SetScreenThreshold(options->GetValue<int>("QwLog.loglevel-screen"));
117 
118  // Set color flag
119  SetScreenColor(options->GetValue<bool>("QwLog.color"));
120 
121  // Set the flags for function name and signature printing
122  fPrintFunctionSignature = options->GetValue<bool>("QwLog.print-signature");
123 
124  // Set the list of regular expressions for functions to debug
125  fDebugFunctionRegexString = options->GetValueVector<std::string>("QwLog.debug-function");
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;
130  }
131 }
void InitLogFile(const std::string name, const std::ios_base::openmode mode=kAppend)
Initialize the log file with name &#39;name&#39;.
Definition: QwLog.cc:157
std::vector< std::string > fDebugFunctionRegexString
Definition: QwLog.h:187
void SetScreenThreshold(int thr)
Set the screen log level.
Definition: QwLog.cc:178
bool HasValue(const std::string &key)
Has this key been defined.
Definition: QwOptions.h:233
std::vector< T > GetValueVector(const std::string &key)
Get a list of templated values.
Definition: QwOptions.h:253
T GetValue(const std::string &key)
Get a templated value.
Definition: QwOptions.h:240
void SetScreenColor(bool flag)
Set the screen color mode.
Definition: QwLog.cc:171
void SetFileThreshold(int thr)
Set the file log level.
Definition: QwLog.cc:185
bool fPrintFunctionSignature
Flag to print function signature on warning or error.
Definition: QwLog.h:183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwLog::SetFileThreshold ( int  thr)

Set the file log level.

Set the file log level

Definition at line 185 of file QwLog.cc.

References fFileThreshold.

Referenced by main(), and ProcessOptions().

186 {
187  fFileThreshold = QwLogLevel(thr);
188 }
QwLogLevel fFileThreshold
File thresholds and stream.
Definition: QwLog.h:177
QwLogLevel
Loglevels.
Definition: QwLog.h:93

+ Here is the caller graph for this function:

void QwLog::SetScreenColor ( bool  flag)

Set the screen color mode.

Set the screen color mode

Definition at line 171 of file QwLog.cc.

References fUseColor.

Referenced by main(), and ProcessOptions().

172 {
173  fUseColor = flag;
174 }
bool fUseColor
Flag to disable color.
Definition: QwLog.h:190

+ Here is the caller graph for this function:

void QwLog::SetScreenThreshold ( int  thr)

Set the screen log level.

Set the screen log level

Definition at line 178 of file QwLog.cc.

References fScreenThreshold.

Referenced by main(), and ProcessOptions().

179 {
181 }
QwLogLevel fScreenThreshold
Screen thresholds and stream.
Definition: QwLog.h:174
QwLogLevel
Loglevels.
Definition: QwLog.h:93

+ Here is the caller graph for this function:

Field Documentation

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

Definition at line 187 of file QwLog.h.

Referenced by IsDebugFunction(), and ProcessOptions().

std::ostream* QwLog::fFile
private

Definition at line 178 of file QwLog.h.

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

bool QwLog::fFileAtNewLine = true
staticprivate

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

Definition at line 193 of file QwLog.h.

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

QwLogLevel QwLog::fFileThreshold
private

File thresholds and stream.

Definition at line 177 of file QwLog.h.

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

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

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

Definition at line 186 of file QwLog.h.

Referenced by IsDebugFunction().

QwLogLevel QwLog::fLogLevel
private

Log level of this stream.

Definition at line 180 of file QwLog.h.

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

bool QwLog::fPrintFunctionSignature
private

Flag to print function signature on warning or error.

Definition at line 183 of file QwLog.h.

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

std::ostream* QwLog::fScreen
private

Definition at line 175 of file QwLog.h.

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

bool QwLog::fScreenAtNewLine = true
staticprivate

Definition at line 195 of file QwLog.h.

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

bool QwLog::fScreenInColor = false
staticprivate

Definition at line 194 of file QwLog.h.

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

QwLogLevel QwLog::fScreenThreshold
private

Screen thresholds and stream.

Definition at line 174 of file QwLog.h.

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

char QwLog::fTimeString[128]
private

Definition at line 171 of file QwLog.h.

Referenced by GetTime().

bool QwLog::fUseColor
private

Flag to disable color.

Definition at line 190 of file QwLog.h.

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

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

Definition at line 104 of file QwLog.h.

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

Log file open modes.

Definition at line 103 of file QwLog.h.

Referenced by main().


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