Skip to content
Snippets Groups Projects
Commit 20ecef1f authored by Marco Biasini's avatar Marco Biasini
Browse files

added SCRIPT logging level

parent 56874070
Branches
Tags 1.0.0
No related merge requests found
......@@ -19,10 +19,10 @@ OpenStructure has a logging system going beyond what print statements can offer.
.. note::
In C++, the logging facility is implemented as a set of macros, called
`LOG_ERROR`, `LOG_WARNING`, `LOG_INFO`, `LOG_VERBOSE`, `LOG_DEBUG` and
`LOG_TRACE`. The last two are only active when compiling with debugging
symbols. When debugging symbols are off, they expand to an empty macro and
thus don't create any overhead.
`LOG_ERROR`, `LOG_WARNING`, `LOG_SCRIPT`, `LOG_INFO`, `LOG_VERBOSE`,
`LOG_DEBUG` and `LOG_TRACE`. The last two are only active when compiling with
debugging symbols. When debugging symbols are off, they expand to an empty
macro and thus don't create any overhead.
Verbosity Level
......@@ -34,7 +34,7 @@ You can change the verbosity level with the following two methods:
Change the verbosity level to the given integer value. All log events
which have a severity above verbosity will be ignored. By default, the log
level is 2, meaning that errors, warnings and info logging events are
level is 2, meaning that errors, warnings and script logging events are
visible.
:type verbosity: :class:`int`
......@@ -140,10 +140,14 @@ WARNING:
Diagnose potential problems that do not abort the execution, but may
point to a misconfiguration/misuse. This level is turned on by default.
SCRIPT:
Logging level that should be used from scripts, e.g. to report progress. These
logging messages are turned on by default.
INFO:
Informative and important messages that summarize a complex command, such as
information on a loaded file, or results from an algorithm. These logging
messages are turned on by default.
messages are not turned on by default.
VERBOSE:
Grey-zone between user and developer need, and perhaps the hardest to get
......@@ -178,7 +182,7 @@ terminal (or the python shell in DNG). The logger also prints the current time.
ost.LogSink.__init__(self)
def LogMessage(self, message, severity):
levels=['ERROR', 'WARNING', 'INFO',
levels=['ERROR', 'WARNING', 'SCRIPT', 'INFO',
'VERBOSE', 'DEBUG', 'TRACE']
level=levels[severity]
print '%s[%s]: %s' % (level, str(datetime.datetime.now()), message),
......
......@@ -73,6 +73,7 @@ void pop_log_sink()
void log_error(const String& m) {LOG_ERROR(m);}
void log_warning(const String& m) {LOG_WARNING(m);}
void log_script(const String& m) {LOG_SCRIPT(m);}
void log_info(const String& m) {LOG_INFO(m);}
void log_verbose(const String& m) {LOG_VERBOSE(m);}
......@@ -109,6 +110,7 @@ void export_Logger()
def("LogError",log_error);
def("LogWarning",log_warning);
def("LogInfo",log_info);
def("LogScript", log_script)
def("LogVerbose", log_verbose);
// this relatively ugly construct is required to work around a problem with
......
......@@ -35,10 +35,11 @@ public:
enum LogLevel {
QUIET =0,
WARNING =1,
INFO =2,
VERBOSE =3,
DEBUG =4,
TRACE =5
SCRIPT =2,
INFO =3,
VERBOSE =4,
DEBUG =5,
TRACE =6
};
void PushVerbosityLevel(int level);
......@@ -82,6 +83,7 @@ private:
#define LOG_ERROR(m) OST_DO_LOGGING_(m, ::ost::Logger::QUIET)
#define LOG_WARNING(m) OST_DO_LOGGING_(m, ::ost::Logger::WARNING)
#define LOG_SCRIPT(m) OST_DO_LOGGING_(m, ::ost::Logger::SCRIPT)
#define LOG_INFO(m) OST_DO_LOGGING_(m, ::ost::Logger::INFO)
#define LOG_VERBOSE(m) OST_DO_LOGGING_(m, ::ost::Logger::VERBOSE)
#ifdef NDEBUG
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment