9#include <Poco/Logger.h>
10#include <Poco/NullStream.h>
20Poco::NullOutputStream NULL_STREAM;
24 "PRIO_ERROR",
"PRIO_WARNING",
"PRIO_NOTICE",
25 "PRIO_INFORMATION",
"PRIO_DEBUG",
"PRIO_TRACE"};
39 auto *logger = &Poco::Logger::get(name);
40 auto logStream = std::make_unique<ThreadSafeLogStream>(*logger);
129void Logger::dump(
const std::string &msg,
const void *buffer, std::size_t length) {
132 m_log->dump(msg, buffer, length);
133 }
catch (std::exception &e) {
136 std::cerr << e.what();
149 retVal =
m_log->is(level);
150 }
catch (std::exception &e) {
153 std::cerr << e.what();
160 m_log->setLevel(level);
161 }
catch (std::exception &e) {
164 std::cerr << e.what();
174 m_log->setLevel(level);
175 }
catch (std::exception &e) {
178 std::cerr << e.what();
285 Poco::Logger::shutdown();
286 }
catch (std::exception &e) {
289 std::cerr << e.what();
299 Poco::Logger::setLevel(
"", level);
312 case Poco::Message::PRIO_FATAL:
313 m_log->fatal(message);
315 case Poco::Message::PRIO_CRITICAL:
316 m_log->critical(message);
318 case Poco::Message::PRIO_ERROR:
319 m_log->error(message);
321 case Poco::Message::PRIO_WARNING:
322 m_log->warning(message);
324 case Poco::Message::PRIO_NOTICE:
325 m_log->notice(message);
327 case Poco::Message::PRIO_INFORMATION:
328 m_log->information(message);
330 case Poco::Message::PRIO_DEBUG:
331 m_log->debug(message);
333 case Poco::Message::PRIO_TRACE:
334 m_log->trace(message);
339 }
catch (std::exception &e) {
342 std::cerr <<
"Error in logging framework: " << e.what();
356 case Poco::Message::PRIO_FATAL:
359 case Poco::Message::PRIO_CRITICAL:
362 case Poco::Message::PRIO_ERROR:
365 case Poco::Message::PRIO_WARNING:
368 case Poco::Message::PRIO_NOTICE:
371 case Poco::Message::PRIO_INFORMATION:
374 case Poco::Message::PRIO_DEBUG:
388 int retVal = proposedLevel;
391 return proposedLevel;
394 if (retVal <
static_cast<int>(Priority::PRIO_FATAL)) {
395 retVal = Priority::PRIO_FATAL;
396 }
else if (retVal >
static_cast<int>(Priority::PRIO_TRACE)) {
397 retVal = Priority::PRIO_TRACE;
The Logger class is in charge of the publishing messages from the framework through various channels.
void flushInformation()
flushes the accumulated message with information priority
void flushFatal()
flushes the accumulated message with fatal priority
void dump(const std::string &msg, const void *buffer, std::size_t length)
Logs the given message at debug level, followed by the data in buffer.
static const std::string * PriorityNames
void setName(const std::string &name)
Update the name of the logger.
std::ostream & error()
Logs at error level.
int getLevelOffset() const
Gets the Logger's log offset level.
static void setLevelForAll(const int level)
Sets the log level for all Loggers created so far, including the root logger.
bool m_enabled
The state of this logger, disabled loggers send no messages.
static void shutdown()
Shuts down the logging framework and releases all Loggers.
void flushDebug()
flushes the accumulated message with debug priority
Priority applyLevelOffset(Priority proposedLevel)
Return a log stream set with the given priority.
void setEnabled(const bool enabled)
set if the logging is enabled
void flushError()
flushes the accumulated message with error priority
Poco::Message::Priority Priority
void log(const std::string &message, const Priority &priority)
Log a message at a given priority.
void setLevel(int level)
Sets the Logger's log level.
std::ostream & getLogStream(const Priority &priority)
gets the correct log stream for a priority
Poco::Logger * m_log
Internal handle to third party logging objects.
int getLevel() const
Returns the Logger's log level.
bool getEnabled() const
returns true if the log is enabled
std::ostream & warning()
Logs at warning level.
bool is(int level) const
Returns true if at least the given log level is set.
std::ostream & debug()
Logs at debug level.
void setLevelOffset(int level)
Sets the Logger's log offset level.
std::ostream & notice()
Logs at notice level.
std::ostream & information()
Logs at information level.
std::unique_ptr< ThreadSafeLogStream > m_logStream
Allows stream operators for a logger.
std::ostream & fatal()
Logs at Fatal level.
void purge()
flushes the accumulated messages without logging them
void flush()
flushes accumulated messages to the current level
void flushWarning()
flushes the accumulated message with warning priority
int m_levelOffset
The offset of the logger.
void flushNotice()
flushes the accumulated message with notice priority
void accumulate(const std::string &msg)
accumulates a message
The main log stream class implementing an ostream interface to a Logger.
static const std::string PriorityNames_data[]
void swap(MultiFileValidator &obj1, MultiFileValidator &obj2)