Public Types |
Public Member Functions |
Static Public Member Functions |
Public Attributes |
Protected Member Functions |
Static Protected Member Functions |
Private Attributes |
Static Private Attributes |
Friends
Log Class Reference
Collaboration diagram for Log:
![]()
Detailed DescriptionDefinition at line 9 of file Logging.hh. Member Typedef Documentation
Typedef for a collection of shell color codes, accessed by log level. Definition at line 24 of file Logging.hh.
Typedef for a collection of named log levels. Definition at line 21 of file Logging.hh. Typedef for a collection of named logs. Definition at line 18 of file Logging.hh. Member Enumeration Documentation
Constructor & Destructor Documentation
Constructor 2. Definition at line 23 of file Logging.cc. Member Function Documentation
Definition at line 131 of file Logging.hh. References Log::DEBUG, and Log::log().
Definition at line 137 of file Logging.hh. References Log::ERROR, and Log::log().
Turn a message string into the current log format. Definition at line 146 of file Logging.cc. References Log::endColorCode, Log::getColorCode(), Log::getLevelName(), Log::getName(), Log::showLoggerName, Log::showLogLevel, Log::showTimestamp, and Log::useShellColors. Referenced by Log::log(), and Rivet::operator<<(). { string out; if (Log::useShellColors) { out += getColorCode(level); } if (Log::showLoggerName) { out += getName(); out += ": "; } if (Log::showLogLevel) { out += Log::getLevelName(level); out += " "; } if (Log::showTimestamp) { time_t rawtime; time(&rawtime); char* timestr = ctime(&rawtime); timestr[24] = ' '; out += timestr; out += " "; } if (Log::useShellColors) { out += endColorCode; } out += " "; out += message; return out; }
Definition at line 109 of file Logging.cc. References Log::colorCodes, Log::DEBUG, Log::endColorCode, Log::ERROR, Log::INFO, Log::TRACE, Log::useShellColors, and Log::WARN. Referenced by Log::formatMessage(). { if (!Log::useShellColors) return ""; // If the codes haven't been initialized, do so now. if (Log::colorCodes.empty()) { // If stdout is a valid tty, try to use the appropriate codes. if (isatty(1)) { /// @todo Test for VT100 compliance? Log::colorCodes[TRACE] = "\033[0;36m"; Log::colorCodes[DEBUG] = "\033[0;34m"; Log::colorCodes[INFO] = "\033[0;32m"; Log::colorCodes[WARN] = "\033[0;33m"; Log::colorCodes[ERROR] = "\033[0;31m"; Log::endColorCode = "\033[0m"; } else { Log::colorCodes[TRACE] = ""; Log::colorCodes[DEBUG] = ""; Log::colorCodes[INFO] = ""; Log::colorCodes[WARN] = ""; Log::colorCodes[ERROR] = ""; } } // Return the appropriate code from the colour map. /// @todo Do the map::upper_limit thing to find nearest level... return colorCodes[level]; }
Get the priority level of this logger. Definition at line 95 of file Logging.hh. References Log::_level. { return _level; }
Get a log level enum from a string. Definition at line 136 of file Logging.cc. References Log::DEBUG, Log::ERROR, Log::INFO, Log::TRACE, and Log::WARN.
Get the std::string representation of a log level.
Definition at line 89 of file Logging.cc. References Log::DEBUG, Log::ERROR, Log::INFO, Log::TRACE, and Log::WARN. Referenced by Log::formatMessage(). { /// @todo Do the map::upper_limit thing to find nearest level... switch(level) { case TRACE: return "TRACE"; case DEBUG: return "DEBUG"; case INFO: return "INFO"; case WARN: return "WARN"; case ERROR: return "ERROR"; default: return ""; } //throw Error("Enum value was not a valid log level. How did that happen?"); } Get a logger with the given name. The level will be taken from the "requestedLevels" static map or will be INFO by default. Definition at line 55 of file Logging.cc. References Log::defaultLevels, Log::existingLogs, Log::INFO, and Log::Log(). Referenced by Event::_geNormAlignment(), Run::init(), mt2::mt2_bisect(), mt2::mt2_massless(), Run::openFile(), Run::processEvent(), and Run::readEvent(). { if (existingLogs.find(name) == existingLogs.end()) { int level = INFO; // Try running through all parent classes to find an existing level string tmpname = name; bool triedAllParents = false; while (! triedAllParents) { // Is there a default level? if (defaultLevels.find(tmpname) != defaultLevels.end()) { level = defaultLevels.find(tmpname)->second; break; } // Is there already such a logger? (NB. tmpname != name) if (existingLogs.find(tmpname) != existingLogs.end()) { level = existingLogs.find(tmpname)->second->getLevel(); break; } // Crop the string back to the next parent level size_t lastDot = tmpname.find_last_of("."); if (lastDot != string::npos) { tmpname = tmpname.substr(0, lastDot); } else { triedAllParents = true; } } // for (LevelMap::const_iterator l = defaultLevels.begin(); l != defaultLevels.end(); ++l) { // // } existingLogs[name] = new Log(name, level); } return *existingLogs[name]; }
Get the name of this logger. Definition at line 112 of file Logging.hh. References Log::_name. Referenced by Log::formatMessage(). { return _name; }
Definition at line 133 of file Logging.hh. References Log::INFO, and Log::log().
Will this log level produce output on this logger at the moment? Definition at line 123 of file Logging.hh. References Log::_level. Referenced by Event::_geNormAlignment(), InvMassFinalState::calc(), Log::log(), Rivet::operator<<(), ChargedFinalState::project(), InitialQuarks::project(), PromptFinalState::project(), and VetoedFinalState::project(). { return (level >= _level); }
Write a message at a particular level. Definition at line 182 of file Logging.cc. References Log::formatMessage(), and Log::isActive(). Referenced by Log::debug(), Log::error(), Log::info(), Log::trace(), and Log::warn(). { if (isActive(level)) { cout << formatMessage(level, message) << endl; } }
Set the log levels. Definition at line 40 of file Logging.cc. References Rivet::_updateLevels(), Log::defaultLevels, and Log::existingLogs. { defaultLevels[name] = level; //cout << name << " -> " << level << endl; _updateLevels(defaultLevels, existingLogs); } Set the priority level of this logger. Definition at line 100 of file Logging.hh. References Log::_level. { _level = level; return *this; } Definition at line 47 of file Logging.cc. References Rivet::_updateLevels(), Log::defaultLevels, and Log::existingLogs. { for (LevelMap::const_iterator lev = logLevels.begin(); lev != logLevels.end(); ++lev) { defaultLevels[lev->first] = lev->second; } _updateLevels(defaultLevels, existingLogs); } Set the name of this logger. Definition at line 117 of file Logging.hh. References Log::_name. { _name = name; return *this; }
Definition at line 60 of file Logging.hh. References Log::showLogLevel. { showLogLevel = showLevel; }
Definition at line 64 of file Logging.hh. References Log::showLoggerName. { showLoggerName = showName; }
Definition at line 56 of file Logging.hh. References Log::showTimestamp. { showTimestamp = showTime; }
Definition at line 68 of file Logging.hh. References Log::useShellColors. { useShellColors = useColors; }
Definition at line 129 of file Logging.hh. References Log::log(), and Log::TRACE.
Definition at line 135 of file Logging.hh. References Log::log(), and Log::WARN. Friends And Related Function Documentation
The streaming operator can use Log's internals. Member Data Documentation
Threshold level for this logger. Definition at line 145 of file Logging.hh. Referenced by Log::getLevel(), Log::isActive(), and Log::setLevel().
This logger's name. Definition at line 142 of file Logging.hh. Referenced by Log::getName(), and Log::setName().
A null output stream, used for piping discarded output to nowhere.
Definition at line 158 of file Logging.hh. Referenced by Rivet::operator<<().
A static map of shell color codes for the log levels. Definition at line 34 of file Logging.hh. Referenced by Log::getColorCode().
A static map of default log levels. Definition at line 31 of file Logging.hh. Referenced by Log::getLog(), Log::setLevel(), and Log::setLevels().
Shell color code for the end of the log levels. Definition at line 37 of file Logging.hh. Referenced by Log::formatMessage(), and Log::getColorCode().
A static map of existing logs: we don't make more loggers than necessary. Definition at line 28 of file Logging.hh. Referenced by Log::getLog(), Log::setLevel(), and Log::setLevels().
Show logger name? Definition at line 46 of file Logging.hh. Referenced by Log::formatMessage(), and Log::setShowLoggerName().
Show log level? Definition at line 43 of file Logging.hh. Referenced by Log::formatMessage(), and Log::setShowLevel().
Show timestamp? Definition at line 40 of file Logging.hh. Referenced by Log::formatMessage(), and Log::setShowTimestamp().
Use shell colour escape codes? Definition at line 49 of file Logging.hh. Referenced by Log::formatMessage(), Log::getColorCode(), and Log::setUseColors(). The documentation for this class was generated from the following files: Generated on Thu Mar 10 2016 08:30:12 for The Rivet MC analysis system by ![]() |