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

added SCRIPT logging level

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