45 #include <sys/types.h>
97 _globMinLevel =
DEBUG ;
98 _lastMsgLevel =
DEBUG ;
100 _devnull =
new ofstream(
"/dev/null") ;
102 _levelNames[
DEBUG]=
"DEBUG" ;
103 _levelNames[
INFO]=
"INFO" ;
105 _levelNames[
WARNING]=
"WARNING" ;
106 _levelNames[
ERROR]=
"ERROR" ;
107 _levelNames[
FATAL]=
"FATAL" ;
112 _topicNames[
Fitting]=
"Fitting" ;
115 _topicNames[
Eval]=
"Eval" ;
116 _topicNames[
Caching]=
"Caching" ;
120 _topicNames[
Tracing]=
"Tracing" ;
128 _debugWorkspace = 0 ;
143 map<string,ostream*>::iterator
iter = _files.begin() ;
144 for (; iter != _files.end() ; ++
iter) {
145 delete iter->second ;
148 if (_debugWorkspace) {
149 delete _debugWorkspace ;
162 return instance()._debugCount>0 ;
171 if (!_debugWorkspace) {
174 return _debugWorkspace ;
216 pc.
defineInt(
"topic",
"Topic",0,0xFFFFF) ;
233 const char* objName = pc.
getString(
"objName") ;
234 const char* className = pc.
getString(
"className") ;
235 const char* baseClassName = pc.
getString(
"baseClassName") ;
236 const char* tagName = pc.
getString(
"tagName") ;
237 const char* outFile = pc.
getString(
"outFile") ;
240 ostream* os =
reinterpret_cast<ostream*
>(pc.
getObject(
"outStream")) ;
248 newStream.
topic = topic ;
249 newStream.
objectName = (objName ? objName :
"" ) ;
250 newStream.
className = (className ? className :
"" ) ;
251 newStream.
baseClassName = (baseClassName ? baseClassName :
"" ) ;
252 newStream.
tagName = (tagName ? tagName :
"" ) ;
253 newStream.
color = color ;
254 newStream.
prefix = prefix ;
268 }
else if (
string(outFile).size()>0) {
271 ostream* os2 = _files[
"outFile"] ;
276 os2 =
new ofstream(outFile) ;
279 cout <<
"RooMsgService::addReportingStream ERROR: cannot open output log file " << outFile <<
" reverting stream to stdout" << endl ;
281 newStream.
os = &cout ;
287 _files[
"outFile"] = os2 ;
295 newStream.
os = &cout ;
301 _streams.push_back(newStream) ;
304 return _streams.size()-1 ;
314 vector<StreamConfig>::iterator
iter = _streams.begin() ;
318 if (iter->minLevel==
DEBUG) {
322 _streams.erase(iter) ;
332 if (id<0 || id>=static_cast<Int_t>(_streams.size())) {
333 cout <<
"RooMsgService::setStreamStatus() ERROR: invalid stream ID " <<
id << endl ;
338 if (_streams[
id].minLevel==
DEBUG) {
339 _debugCount += flag ? 1 : -1 ;
342 _streams[
id].active = flag ;
352 if (id<0 || id>= static_cast<Int_t>(_streams.size())) {
353 cout <<
"RooMsgService::getStreamStatus() ERROR: invalid stream ID " <<
id << endl ;
356 return _streams[
id].active ;
380 _streamsSaved.push(_streams) ;
390 _streams = _streamsSaved.top() ;
391 _streamsSaved.pop() ;
401 return (activeStream(
self,topic,level)>=0) ;
410 return (activeStream(
self,topic,level)>=0) ;
419 if (level<_globMinLevel)
return -1 ;
420 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
421 if (_streams[i].match(level,topic,
self)) {
434 if (level<_globMinLevel)
return -1 ;
435 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
436 if (_streams[i].match(level,topic,
self)) {
449 if (!active)
return kFALSE ;
450 if (level<minLevel)
return kFALSE ;
451 if (!(topic&top))
return kFALSE ;
453 if (universal)
return kTRUE ;
455 if (objectName.size()>0 && objectName != obj->
GetName())
return kFALSE ;
456 if (className.size()>0 && className != obj->IsA()->
GetName())
return kFALSE ;
457 if (baseClassName.size()>0 && !obj->IsA()->
InheritsFrom(baseClassName.c_str()))
return kFALSE ;
469 if (!active)
return kFALSE ;
470 if (level<minLevel)
return kFALSE ;
471 if (!(topic&top))
return kFALSE ;
473 if (universal)
return kTRUE ;
475 if (objectName.size()>0 && objectName != obj->
GetName())
return kFALSE ;
476 if (className.size()>0 && className != obj->IsA()->
GetName())
return kFALSE ;
477 if (baseClassName.size()>0 && !obj->IsA()->
InheritsFrom(baseClassName.c_str()))
return kFALSE ;
495 Int_t as = activeStream(
self,topic,level) ;
502 (*_streams[
as].os).flush() ;
506 (*_streams[
as].os) << endl ;
508 _lastMsgLevel=level ;
510 if (_streams[as].prefix && !skipPrefix) {
514 (*_streams[
as].os) <<
"[#" << as <<
"] " << _levelNames[level] <<
":" << _topicNames[topic] <<
" -- " ;
516 return (*_streams[as].os) ;
532 Int_t as = activeStream(
self,topic,level) ;
538 (*_streams[
as].os).flush() ;
540 if (_streams[as].prefix && !skipPrefix) {
544 (*_streams[
as].os) <<
"[#" << as <<
"] " << _levelNames[level] <<
":" << _topicNames[topic] <<
" -- " ;
546 return (*_streams[as].os) ;
558 if (
TString(options).Contains(
"V") ||
TString(options).Contains(
"v")) {
562 cout << (activeOnly?
"Active Message streams":
"All Message streams") << endl ;
563 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
566 if (activeOnly && !_streams[i].active) {
571 map<int,string>::const_iterator is = _levelNames.find(_streams[i].minLevel) ;
572 cout <<
"[" << i <<
"] MinLevel = " << is->second ;
574 cout <<
" Topic = " ;
575 if (_streams[i].topic != 0xFFFFF) {
576 map<int,string>::const_iterator
iter = _topicNames.begin() ;
577 while(iter!=_topicNames.end()) {
578 if (iter->first & _streams[i].topic) {
579 cout << iter->second <<
" " ;
588 if (_streams[i].objectName.size()>0) {
589 cout <<
" ObjectName = " << _streams[i].objectName ;
591 if (_streams[i].className.size()>0) {
592 cout <<
" ClassName = " << _streams[i].className ;
594 if (_streams[i].baseClassName.size()>0) {
595 cout <<
" BaseClassName = " << _streams[i].baseClassName ;
597 if (_streams[i].tagName.size()>0) {
598 cout <<
" TagLabel = " << _streams[i].tagName ;
602 if (!activeOnly && !_streams[i].active) {
603 cout <<
" (NOT ACTIVE)" ;
Bool_t getStreamStatus(Int_t id) const
Get activation status of stream with given unique ID.
RooFit::MsgLevel minLevel
virtual int GetPid()
Get process id.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
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'.
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
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...
std::map< std::string, std::string >::const_iterator iter
RooMsgService()
Constructor.
if on multiple lines(like in C++).**The" * configuration fragment. * * The "import myobject continue
Parses the configuration file.
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...
void saveState()
Save current state of message service.
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...
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)
char * Form(const char *fmt,...)
virtual const char * GetName() const
Returns name of object.
Bool_t ok(Bool_t verbose) const
Return true of parsing was successful.
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...
static void activate()
Install atexit handler that calls CleanupRooFitAtExit() on program termination.
virtual const char * GetName() const
Returns name of object.
virtual ~RooMsgService()
Destructor.
std::string baseClassName
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.
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...
RooWorkspace * debugWorkspace()
void Print(Option_t *options=0) const
Print configuration of message service.
void restoreState()
Restore last saved state of message service.