9#include <boost/python/class.hpp>
10#include <boost/python/make_constructor.hpp>
11#include <boost/python/reference_existing_object.hpp>
12#include <boost/python/register_ptr_to_python.hpp>
27std::shared_ptr<Logger> getLogger(
const std::string &name) {
28 PyErr_Warn(PyExc_DeprecationWarning,
"Logger.get(\"name\") is deprecated. "
29 "Simply use Logger(\"name\") instead");
30 return std::make_shared<Logger>(name);
33std::shared_ptr<Logger> create(
const std::string &name) {
return std::make_shared<Logger>(name); }
35void fatal(
Logger *self,
const std::string &message) {
40void error(
Logger *self,
const std::string &message) {
45void warning(
Logger *self,
const std::string &message) {
50void notice(
Logger *self,
const std::string &message) {
55void information(
Logger *self,
const std::string &message) {
60void debug(
Logger *self,
const std::string &message) {
68 register_ptr_to_python<std::shared_ptr<Logger>>();
70 class_<Logger, boost::noncopyable>(
"Logger", init<std::string>((arg(
"self"), arg(
"name"))))
71 .def(
"__init__", make_constructor(&create, default_call_policies(), args(
"name")))
72 .def(
"fatal", fatal, (arg(
"self"), arg(
"message")),
73 "Send a message at fatal priority: "
74 "An unrecoverable error has occured and the application will "
76 .def(
"error",
error, (arg(
"self"), arg(
"message")),
77 "Send a message at error priority: "
78 "An error has occured but the framework is able to handle it and "
80 .def(
"warning", warning, (arg(
"self"), arg(
"message")),
81 "Send a message at warning priority: "
82 "Something was wrong but the framework was able to continue despite "
84 .def(
"notice", notice, (arg(
"self"), arg(
"message")),
85 "Sends a message at notice priority: "
86 "Really important information that should be displayed to the user, "
87 "this should be minimal. The default logging level is set here "
88 "unless it is altered.")
89 .def(
"information", information, (arg(
"self"), arg(
"message")),
90 "Send a message at information priority: "
91 "Useful but not vital information to be relayed back to the user.")
92 .def(
"debug", debug, (arg(
"self"), arg(
"message")),
93 "Send a message at debug priority:"
94 ". Anything that may be useful to understand what the code has been "
95 "doing for debugging purposes.")
97 "accumulate a message to report later")
99 "Flush the accumulated message to the current channel.")
101 "Flush the accumulated message to the debug channel.")
103 "Flush the accumulated message to the debug channel.")
105 "Flush the accumulated message to the notice channel.")
107 "Flush the accumulated message to the warning channel.")
109 "Flush the accumulated message to the error channel.")
111 "Flush the accumulated message to the fatal channel.")
113 "Clear the accumulated messages without logging.")
115 .def(
"get", &getLogger,
116 "Creates the named logger. "
117 "This method is static, call as Logger.get('logger_name'). The name "
118 "is used as a prefix within the "
119 "log file so that msg origins can be traced more easily.")
120 .staticmethod(
"get");
void(Logger::*)(const std::string &) LoggerMsgFunction
void(Logger::*)() LoggerFlushFunction
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 debug(const std::string &msg)
Logs at debug level.
void notice(const std::string &msg)
Logs at notice level.
void error(const std::string &msg)
Logs at error level.
void flushDebug()
flushes the accumulated message with debug priority
void warning(const std::string &msg)
Logs at warning level.
void flushError()
flushes the accumulated message with error priority
void fatal(const std::string &msg)
Logs at Fatal level.
void information(const std::string &msg)
Logs at information 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
void flushNotice()
flushes the accumulated message with notice priority
void accumulate(const std::string &msg)
accumulates a message
Defines a structure for releasing the Python GIL using the RAII pattern.