15 #include "libxml/parser.h" 16 #include "libxml/xmlmemory.h" 17 #include "log4cpp/SimpleLayout.hh" 32 using namespace genie;
61 log4cpp::Appender * appender;
62 appender =
new log4cpp::OstreamAppender(
"default", &cout);
63 const char* layoutenv = gSystem->Getenv(
"GMSGLAYOUT");
64 std::string layoutstr = (layoutenv) ?
string(layoutenv) :
"BASIC";
65 if ( layoutstr ==
"SIMPLE" )
66 appender->setLayout(
new log4cpp::SimpleLayout());
68 appender->setLayout(
new log4cpp::BasicLayout());
71 log4cpp::Category & MSG = log4cpp::Category::getRoot();
73 MSG.setAdditivity(
false);
74 MSG.addAppender(appender);
83 log4cpp::Category & MSG = log4cpp::Category::getInstance(stream);
89 const char *
stream, log4cpp::Priority::Value priority)
91 log4cpp::Category & MSG = log4cpp::Category::getInstance(stream);
93 MSG.setPriority(priority);
109 <<
"Priority levels from: " << msg_config_file <<
" were not set!";
124 if(filenames.size()==0)
return false;
127 if(filename_vec.size() == 0)
return false;
130 for(filename_iter = filename_vec.begin();
131 filename_iter != filename_vec.end(); ++filename_iter)
137 <<
"Reading msg stream priorities from XML file: " <<
filename;
139 xmlDocPtr xml_doc = xmlParseFile(filename.c_str());
142 <<
"XML file could not be parsed! [file: " << filename <<
"]";
146 xmlNodePtr xml_root = xmlDocGetRootElement(xml_doc);
149 <<
"XML doc. has null root element! [file: " << filename <<
"]";
154 if( xmlStrcmp(xml_root->name, (
const xmlChar *)
"messenger_config") ) {
156 <<
"XML doc. has invalid root element! [file: " << filename <<
"]";
157 xmlFreeNode(xml_root);
162 xmlNodePtr xml_msgp = xml_root->xmlChildrenNode;
165 while (xml_msgp != NULL) {
168 if( (!xmlStrcmp(xml_msgp->name, (
const xmlChar *)
"priority")) ) {
174 xml_doc, xml_msgp->xmlChildrenNode, 1));
178 <<
"Set priority level: " <<
setfill(
'.')
179 <<
setw(24) << msgstream <<
" --> " << priority;
181 xml_msgp = xml_msgp->next;
185 xmlFreeNode(xml_msgp);
196 if ( p.find(
"NOTICE") != string::npos )
return log4cpp::Priority::NOTICE;
197 if ( p.find(
"WARN") != string::npos )
return log4cpp::Priority::WARN;
199 if ( p.find(
"CRIT") != string::npos )
return log4cpp::Priority::CRIT;
200 if ( p.find(
"ALERT") != string::npos )
return log4cpp::Priority::ALERT;
201 if ( p.find(
"FATAL") != string::npos )
return log4cpp::Priority::FATAL;
204 <<
"Unknown priority = " << p <<
" - Setting to INFO";
THE MAIN GENIE PROJECT NAMESPACE
void DummyMethodAndSilentCompiler()
string TrimSpaces(xmlChar *xmls)
log4cpp::Priority::Value PriorityFromString(string priority)
log4cpp::Category & operator()(const char *stream)
bool SetPrioritiesFromXmlFile(string filename)
static Messenger * Instance(void)
string GetXMLFilePath(string basename)
Q_EXPORT QTSManip setw(int w)
string TrimSpaces(string input)
A more convenient interface to the log4cpp Message Service.
vector< string > Split(string input, string delim)
void SetPriorityLevel(const char *stream, log4cpp::Priority::Value p)
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
Q_EXPORT QTSManip setfill(int f)
static Messenger * fInstance
QTextStream & endl(QTextStream &s)