42 #include <sys/types.h>
61 using namespace RooFit ;
94 _globMinLevel =
DEBUG ;
95 _lastMsgLevel =
DEBUG ;
97 _devnull =
new ofstream(
"/dev/null") ;
99 _levelNames[
DEBUG]=
"DEBUG" ;
100 _levelNames[
INFO]=
"INFO" ;
102 _levelNames[
WARNING]=
"WARNING" ;
103 _levelNames[
ERROR]=
"ERROR" ;
104 _levelNames[
FATAL]=
"FATAL" ;
109 _topicNames[
Fitting]=
"Fitting" ;
112 _topicNames[
Eval]=
"Eval" ;
113 _topicNames[
Caching]=
"Caching" ;
117 _topicNames[
Tracing]=
"Tracing" ;
125 _debugWorkspace = 0 ;
140 map<string,ostream*>::iterator
iter = _files.begin() ;
141 for (; iter != _files.end() ; ++
iter) {
142 delete iter->second ;
145 if (_debugWorkspace) {
146 delete _debugWorkspace ;
159 return instance()._debugCount>0 ;
168 if (!_debugWorkspace) {
171 return _debugWorkspace ;
213 pc.
defineInt(
"topic",
"Topic",0,0xFFFFF) ;
230 const char* objName = pc.
getString(
"objName") ;
231 const char* className = pc.
getString(
"className") ;
232 const char* baseClassName = pc.
getString(
"baseClassName") ;
233 const char* tagName = pc.
getString(
"tagName") ;
234 const char* outFile = pc.
getString(
"outFile") ;
237 ostream* os =
reinterpret_cast<ostream*
>(pc.
getObject(
"outStream")) ;
245 newStream.
topic = topic ;
246 newStream.
objectName = (objName ? objName :
"" ) ;
247 newStream.
className = (className ? className :
"" ) ;
248 newStream.
baseClassName = (baseClassName ? baseClassName :
"" ) ;
249 newStream.
tagName = (tagName ? tagName :
"" ) ;
250 newStream.
color = color ;
251 newStream.
prefix = prefix ;
265 }
else if (
string(outFile).size()>0) {
268 ostream* os2 = _files[
"outFile"] ;
273 os2 =
new ofstream(outFile) ;
276 cout <<
"RooMsgService::addReportingStream ERROR: cannot open output log file " << outFile <<
" reverting stream to stdout" << endl ;
278 newStream.
os = &cout ;
284 _files[
"outFile"] = os2 ;
292 newStream.
os = &cout ;
298 _streams.push_back(newStream) ;
301 return _streams.size()-1 ;
311 vector<StreamConfig>::iterator
iter = _streams.begin() ;
315 if (iter->minLevel==
DEBUG) {
319 _streams.erase(iter) ;
329 if (id<0 || id>=static_cast<Int_t>(_streams.size())) {
330 cout <<
"RooMsgService::setStreamStatus() ERROR: invalid stream ID " <<
id << endl ;
335 if (_streams[
id].minLevel==
DEBUG) {
336 _debugCount += flag ? 1 : -1 ;
339 _streams[
id].active = flag ;
349 if (id<0 || id>= static_cast<Int_t>(_streams.size())) {
350 cout <<
"RooMsgService::getStreamStatus() ERROR: invalid stream ID " <<
id << endl ;
353 return _streams[
id].active ;
377 _streamsSaved.push(_streams) ;
387 _streams = _streamsSaved.top() ;
388 _streamsSaved.pop() ;
398 return (activeStream(
self,topic,level)>=0) ;
407 return (activeStream(
self,topic,level)>=0) ;
416 if (level<_globMinLevel)
return -1 ;
417 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
418 if (_streams[i].match(level,topic,
self)) {
431 if (level<_globMinLevel)
return -1 ;
432 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
433 if (_streams[i].match(level,topic,
self)) {
446 if (!active)
return kFALSE ;
447 if (level<minLevel)
return kFALSE ;
448 if (!(topic&top))
return kFALSE ;
450 if (universal)
return kTRUE ;
452 if (objectName.size()>0 && objectName != obj->
GetName())
return kFALSE ;
453 if (className.size()>0 && className != obj->IsA()->
GetName())
return kFALSE ;
454 if (baseClassName.size()>0 && !obj->IsA()->
InheritsFrom(baseClassName.c_str()))
return kFALSE ;
466 if (!active)
return kFALSE ;
467 if (level<minLevel)
return kFALSE ;
468 if (!(topic&top))
return kFALSE ;
470 if (universal)
return kTRUE ;
472 if (objectName.size()>0 && objectName != obj->
GetName())
return kFALSE ;
473 if (className.size()>0 && className != obj->IsA()->
GetName())
return kFALSE ;
474 if (baseClassName.size()>0 && !obj->IsA()->
InheritsFrom(baseClassName.c_str()))
return kFALSE ;
492 Int_t as = activeStream(
self,topic,level) ;
499 (*_streams[
as].os).flush() ;
503 (*_streams[
as].os) << endl ;
505 _lastMsgLevel=level ;
507 if (_streams[as].prefix && !skipPrefix) {
511 (*_streams[
as].os) <<
"[#" << as <<
"] " << _levelNames[level] <<
":" << _topicNames[topic] <<
" -- " ;
513 return (*_streams[as].os) ;
529 Int_t as = activeStream(
self,topic,level) ;
535 (*_streams[
as].os).flush() ;
537 if (_streams[as].prefix && !skipPrefix) {
541 (*_streams[
as].os) <<
"[#" << as <<
"] " << _levelNames[level] <<
":" << _topicNames[topic] <<
" -- " ;
543 return (*_streams[as].os) ;
555 if (
TString(options).Contains(
"V") ||
TString(options).Contains(
"v")) {
559 cout << (activeOnly?
"Active Message streams":
"All Message streams") << endl ;
560 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
563 if (activeOnly && !_streams[i].active) {
568 map<int,string>::const_iterator is = _levelNames.find(_streams[i].minLevel) ;
569 cout <<
"[" << i <<
"] MinLevel = " << is->second ;
571 cout <<
" Topic = " ;
572 if (_streams[i].topic != 0xFFFFF) {
573 map<int,string>::const_iterator
iter = _topicNames.begin() ;
574 while(iter!=_topicNames.end()) {
575 if (iter->first & _streams[i].topic) {
576 cout << iter->second <<
" " ;
585 if (_streams[i].objectName.size()>0) {
586 cout <<
" ObjectName = " << _streams[i].objectName ;
588 if (_streams[i].className.size()>0) {
589 cout <<
" ClassName = " << _streams[i].className ;
591 if (_streams[i].baseClassName.size()>0) {
592 cout <<
" BaseClassName = " << _streams[i].baseClassName ;
594 if (_streams[i].tagName.size()>0) {
595 cout <<
" TagLabel = " << _streams[i].tagName ;
599 if (!activeOnly && !_streams[i].active) {
600 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...
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...
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,...)
The RooMsgService class is a singleton class that organizes informational, debugging, warning and errors messages generated by the RooFit core code.
virtual const char * GetName() const
Returns name of object.
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
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...
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 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.
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...