42 #include <sys/types.h> 93 _globMinLevel =
DEBUG ;
94 _lastMsgLevel =
DEBUG ;
96 _devnull =
new ofstream(
"/dev/null") ;
98 _levelNames[
DEBUG]=
"DEBUG" ;
99 _levelNames[
INFO]=
"INFO" ;
101 _levelNames[
WARNING]=
"WARNING" ;
102 _levelNames[
ERROR]=
"ERROR" ;
103 _levelNames[
FATAL]=
"FATAL" ;
108 _topicNames[
Fitting]=
"Fitting" ;
111 _topicNames[
Eval]=
"Eval" ;
112 _topicNames[
Caching]=
"Caching" ;
116 _topicNames[
Tracing]=
"Tracing" ;
124 _debugWorkspace = 0 ;
139 map<string,ostream*>::iterator iter = _files.begin() ;
140 for (; iter != _files.end() ; ++iter) {
141 delete iter->second ;
144 if (_debugWorkspace) {
145 delete _debugWorkspace ;
158 return instance()._debugCount>0 ;
167 if (!_debugWorkspace) {
170 return _debugWorkspace ;
212 pc.
defineInt(
"topic",
"Topic",0,0xFFFFF) ;
229 const char* objName = pc.
getString(
"objName") ;
230 const char* className = pc.
getString(
"className") ;
231 const char* baseClassName = pc.
getString(
"baseClassName") ;
232 const char* tagName = pc.
getString(
"tagName") ;
233 const char* outFile = pc.
getString(
"outFile") ;
236 ostream* os =
reinterpret_cast<ostream*
>(pc.
getObject(
"outStream")) ;
244 newStream.
topic = topic ;
245 newStream.
objectName = (objName ? objName :
"" ) ;
246 newStream.
className = (className ? className :
"" ) ;
247 newStream.
baseClassName = (baseClassName ? baseClassName :
"" ) ;
248 newStream.
tagName = (tagName ? tagName :
"" ) ;
249 newStream.
color = color ;
250 newStream.
prefix = prefix ;
264 }
else if (
string(outFile).size()>0) {
267 ostream* os2 = _files[
"outFile"] ;
272 os2 =
new ofstream(outFile) ;
275 cout <<
"RooMsgService::addReportingStream ERROR: cannot open output log file " << outFile <<
" reverting stream to stdout" << endl ;
277 newStream.
os = &cout ;
283 _files[
"outFile"] = os2 ;
291 newStream.
os = &cout ;
297 _streams.push_back(newStream) ;
300 return _streams.size()-1 ;
310 vector<StreamConfig>::iterator iter = _streams.begin() ;
314 if (iter->minLevel==
DEBUG) {
318 _streams.erase(iter) ;
328 if (id<0 || id>=static_cast<Int_t>(_streams.size())) {
329 cout <<
"RooMsgService::setStreamStatus() ERROR: invalid stream ID " <<
id << endl ;
334 if (_streams[
id].minLevel==
DEBUG) {
335 _debugCount += flag ? 1 : -1 ;
338 _streams[
id].active = flag ;
348 if (id<0 || id>= static_cast<Int_t>(_streams.size())) {
349 cout <<
"RooMsgService::getStreamStatus() ERROR: invalid stream ID " <<
id << endl ;
352 return _streams[
id].active ;
376 _streamsSaved.push(_streams) ;
386 _streams = _streamsSaved.top() ;
387 _streamsSaved.pop() ;
397 return (activeStream(
self,topic,level)>=0) ;
406 return (activeStream(
self,topic,level)>=0) ;
415 if (level<_globMinLevel)
return -1 ;
416 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
417 if (_streams[i].match(level,topic,
self)) {
430 if (level<_globMinLevel)
return -1 ;
431 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
432 if (_streams[i].match(level,topic,
self)) {
445 if (!active)
return kFALSE ;
446 if (level<minLevel)
return kFALSE ;
447 if (!(topic&top))
return kFALSE ;
449 if (universal)
return kTRUE ;
451 if (objectName.size()>0 && objectName != obj->
GetName())
return kFALSE ;
452 if (className.size()>0 && className != obj->IsA()->
GetName())
return kFALSE ;
453 if (baseClassName.size()>0 && !obj->IsA()->
InheritsFrom(baseClassName.c_str()))
return kFALSE ;
465 if (!active)
return kFALSE ;
466 if (level<minLevel)
return kFALSE ;
467 if (!(topic&top))
return kFALSE ;
469 if (universal)
return kTRUE ;
471 if (objectName.size()>0 && objectName != obj->
GetName())
return kFALSE ;
472 if (className.size()>0 && className != obj->IsA()->
GetName())
return kFALSE ;
473 if (baseClassName.size()>0 && !obj->IsA()->
InheritsFrom(baseClassName.c_str()))
return kFALSE ;
491 Int_t as = activeStream(
self,topic,level) ;
498 (*_streams[
as].os).flush() ;
502 (*_streams[
as].os) << endl ;
504 _lastMsgLevel=level ;
506 if (_streams[as].prefix && !skipPrefix) {
510 (*_streams[
as].os) <<
"[#" << as <<
"] " << _levelNames[level] <<
":" << _topicNames[topic] <<
" -- " ;
512 return (*_streams[as].os) ;
528 Int_t as = activeStream(
self,topic,level) ;
534 (*_streams[
as].os).flush() ;
536 if (_streams[as].prefix && !skipPrefix) {
540 (*_streams[
as].os) <<
"[#" << as <<
"] " << _levelNames[level] <<
":" << _topicNames[topic] <<
" -- " ;
542 return (*_streams[as].os) ;
554 if (TString(options).Contains(
"V") || TString(options).Contains(
"v")) {
558 cout << (activeOnly?
"Active Message streams":
"All Message streams") << endl ;
559 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
562 if (activeOnly && !_streams[i].active) {
567 map<int,string>::const_iterator is = _levelNames.find(_streams[i].minLevel) ;
568 cout <<
"[" << i <<
"] MinLevel = " << is->second ;
570 cout <<
" Topic = " ;
571 if (_streams[i].topic != 0xFFFFF) {
572 map<int,string>::const_iterator iter = _topicNames.begin() ;
573 while(iter!=_topicNames.end()) {
574 if (iter->first & _streams[i].topic) {
575 cout << iter->second <<
" " ;
584 if (_streams[i].objectName.size()>0) {
585 cout <<
" ObjectName = " << _streams[i].objectName ;
587 if (_streams[i].className.size()>0) {
588 cout <<
" ClassName = " << _streams[i].className ;
590 if (_streams[i].baseClassName.size()>0) {
591 cout <<
" BaseClassName = " << _streams[i].baseClassName ;
593 if (_streams[i].tagName.size()>0) {
594 cout <<
" TagLabel = " << _streams[i].tagName ;
598 if (!activeOnly && !_streams[i].active) {
599 cout <<
" (NOT ACTIVE)" ;
RooFit::MsgLevel minLevel
virtual const char * GetName() const
Returns name of object.
std::string GetName(const std::string &scope_name)
virtual int GetPid()
Get process id.
const char * getString(const char *name, const char *defaultValue="", Bool_t convEmptyToNull=kFALSE)
Return string property registered with name 'name'.
static Bool_t anyDebug()
Returns true if any debug level stream is active.
void deleteStream(Int_t id)
Delete stream with given unique ID code.
Bool_t isActive(const RooAbsArg *self, RooFit::MsgTopic facility, RooFit::MsgLevel level)
Check if logging is active for given object/topic/RooFit::MsgLevel combination.
static RooMsgService & instance()
Return reference to singleton instance.
TObject * getObject(const char *name, TObject *obj=0)
Return TObject property registered with name 'name'.
std::ostream & log(const RooAbsArg *self, RooFit::MsgLevel level, RooFit::MsgTopic facility, Bool_t forceSkipPrefix=kFALSE)
Log error message associated with RooAbsArg object self at given level and topic. ...
void setStreamStatus(Int_t id, Bool_t active)
(De)Activate stream with given unique ID
Bool_t process(const RooCmdArg &arg)
Process given RooCmdArg.
static void cleanup()
Cleanup function called by atexit() handler installed by RooSentinel to delete all global object upon...
Bool_t getStreamStatus(Int_t id) const
Get activation status of stream with given unique ID.
RooMsgService()
Constructor.
Bool_t defineString(const char *name, const char *argName, Int_t stringNum, const char *defValue="", Bool_t appendMode=kFALSE)
Define Double_t property name 'name' mapped to Double_t in slot 'stringNum' in RooCmdArg with name ar...
static RooMsgService * _instance
void saveState()
Save current state of message service.
RooMsgService * gMsgService
Bool_t defineInt(const char *name, const char *argName, Int_t intNum, Int_t defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
virtual void Add(TObject *arg)
void defineMutex(const char *argName1, const char *argName2)
Define arguments named argName1 and argName2 mutually exclusive.
Int_t getInt(const char *name, Int_t defaultValue=0)
Return integer property registered with name 'name'.
R__EXTERN TSystem * gSystem
RooCmdArg Topic(Int_t topic)
Bool_t ok(Bool_t verbose) const
Return true of parsing was successful.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
char * Form(const char *fmt,...)
The RooMsgService class is a singleton class that organizes informational, debugging, warning and errors messages generated by the RooFit core code.
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Int_t addStream(RooFit::MsgLevel level, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg())
Add a message logging stream for message with given RooFit::MsgLevel or higher (i.e.
Int_t activeStream(const RooAbsArg *self, RooFit::MsgTopic facility, RooFit::MsgLevel level)
Find appropriate logging stream for message from given object with given topic and message level...
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
static void activate()
Install atexit handler that calls CleanupRooFitAtExit() on program termination.
virtual ~RooMsgService()
Destructor.
std::string baseClassName
void Print(Option_t *options=0) const
Print configuration of message service.
Mother of all ROOT objects.
Bool_t match(RooFit::MsgLevel level, RooFit::MsgTopic facility, const RooAbsArg *obj)
Determine if message from given object at given level on given topic is logged.
static constexpr double pc
Bool_t defineObject(const char *name, const char *argName, Int_t setNum, const TObject *obj=0, Bool_t isArray=kFALSE)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
virtual const char * GetName() const
Returns name of object.
RooWorkspace * debugWorkspace()
The RooWorkspace is a persistable container for RooFit projects.
void restoreState()
Restore last saved state of message service.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...