A more convenient interface to the log4cpp Message Service.
- Author
- Costas Andreopoulos <c.andreopoulos cern.ch> University of Liverpool
- Created:
- June 16, 2004
- License:
- Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org
Definition at line 258 of file Messenger.h.
bool Messenger::SetPrioritiesFromXmlFile |
( |
string |
filename | ) |
|
Definition at line 114 of file Messenger.cxx.
References genie::utils::xml::GetAttribute(), genie::utils::xml::GetXMLFilePath(), pERROR, pINFO, pNOTICE, PriorityFromString(), SetPriorityLevel(), SLOG, genie::utils::str::Split(), genie::utils::str::TrimSpaces(), and genie::utils::xml::TrimSpaces().
Referenced by Configure(), and genie::utils::app_init::MesgThresholds().
124 if(filenames.size()==0)
return false;
127 if(filename_vec.size() == 0)
return false;
129 vector<string>::const_iterator filename_iter;
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);
string TrimSpaces(xmlChar *xmls)
log4cpp::Priority::Value PriorityFromString(string priority)
string GetXMLFilePath(string basename)
string TrimSpaces(string input)
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)