diff --git a/modules/base/doc/logging.rst b/modules/base/doc/logging.rst index 8e7ebe76d7e6e7d9e2a289442704b06042e17c79..1a81d479490ced8accd47006543a4c9c247b6749 100644 --- a/modules/base/doc/logging.rst +++ b/modules/base/doc/logging.rst @@ -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), diff --git a/modules/base/pymod/export_logger.cc b/modules/base/pymod/export_logger.cc index 7f29c16e51a935b65b395dfad2ed083c8a7c6da5..5ffb101bd691ee94f21f3d0f7ffd1fea00d0c72e 100644 --- a/modules/base/pymod/export_logger.cc +++ b/modules/base/pymod/export_logger.cc @@ -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 diff --git a/modules/base/src/log.hh b/modules/base/src/log.hh index 4ed5c7ed5d42d62e0452e91e38c830da61091384..b535346f3caeae6f56c2809d5453a0ca78ef3ff6 100644 --- a/modules/base/src/log.hh +++ b/modules/base/src/log.hh @@ -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