Skip to content
Snippets Groups Projects
Commit 56414555 authored by Gerardo Tauriello's avatar Gerardo Tauriello
Browse files

Make LogLevel enum available to Python and document GetVerbosityLevel.

parent ec529c4e
No related branches found
No related tags found
No related merge requests found
...@@ -45,11 +45,12 @@ You can change the verbosity level with the following two methods: ...@@ -45,11 +45,12 @@ You can change the verbosity level with the following two methods:
.. function:: PushVerbosityLevel(verbosity) .. function:: PushVerbosityLevel(verbosity)
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
which have a severity above verbosity will be ignored. By default, the log have a severity above *verbosity* will not be shown. By default, the log level
level is 2, meaning that errors, warnings and script logging events are is 2, meaning that errors, warnings and script logging events are visible. By
visible. By setting it to -1, you can disable all logging. setting it to -1, you can disable all logging.
:param verbosity: Desired verbosity level
:type verbosity: :class:`int` :type verbosity: :class:`int`
.. function:: PopVerbosityLevel() .. function:: PopVerbosityLevel()
...@@ -57,6 +58,17 @@ You can change the verbosity level with the following two methods: ...@@ -57,6 +58,17 @@ You can change the verbosity level with the following two methods:
Change the log level back to the previous verbosity level. It is an error to Change the log level back to the previous verbosity level. It is an error to
pop the verbosity level without a matching call to pop the verbosity level without a matching call to
:func:`PushVerbosityLevel`. :func:`PushVerbosityLevel`.
.. function:: GetVerbosityLevel()
:return: The current verbosity level
:rtype: :class:`int`
.. class:: LogLevel
Enumerates the logging levels (see :ref:`picking-logging-level`). Values:
Error, Warning, Script, Info, Verbose, Debug, Trace
Log sinks Log sinks
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
...@@ -149,36 +161,36 @@ Guidelines for picking logging level ...@@ -149,36 +161,36 @@ Guidelines for picking logging level
Each logging event has an associated level that marks its importance. For example, users should always see errors, but they do not need to see detailed information on the loading process. Here is a list of guidelines that we use in the code. We encourage developers to adhere to these guidelines as closely as possible. Each logging event has an associated level that marks its importance. For example, users should always see errors, but they do not need to see detailed information on the loading process. Here is a list of guidelines that we use in the code. We encourage developers to adhere to these guidelines as closely as possible.
ERROR: **Error**:
Cannot be silenced, very important message to the user, some command did not Very important message to the user, some command did not complete as expected
complete as expected or was aborted. or was aborted.
WARNING: **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: **Script**:
Logging level that should be used from scripts, e.g. to report progress. These Logging level that should be used from scripts, e.g. to report progress. These
logging messages are turned on by default. 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 not 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
right. This is the lowest logging level users will be able to see when they right. This is the lowest logging level users will be able to see when they
use an optimized build. An example for this is the OpenGL setup/info in gfx, use an optimized build. An example for this is the OpenGL setup/info in gfx,
or the path search during startup, or more detailed info on file IO. These or the path search during startup, or more detailed info on file IO. These
messages are not turned on by default. messages are not turned on by default.
DEBUG: **Debug**:
For developers, but not quite at the trace level. This level is turned off by For developers, but not quite at the trace level. This level is turned off by
default, not available in Python and only enabled when compiling with default, not available in Python and only enabled when compiling with
debugging symbols. debugging symbols.
TRACE: **Trace**:
Used to debug inner loops. Once turned on, you will probably get more debug Used to debug inner loops. Once turned on, you will probably get more debug
output that you will be able to handle. This level is turned off by default, output that you will be able to handle. This level is turned off by default,
not available in python and only enabled when compiling with debugging not available in python and only enabled when compiling with debugging
......
...@@ -175,12 +175,22 @@ void export_Logger() ...@@ -175,12 +175,22 @@ void export_Logger()
.def("GetLog", &StringLogSink::GetLog) .def("GetLog", &StringLogSink::GetLog)
; ;
def("PushVerbosityLevel",push_verb); enum_<Logger::LogLevel>("LogLevel")
def("PopVerbosityLevel",pop_verb); .value("Error", Logger::QUIET)
def("GetVerbosityLevel",get_verb); .value("Warning", Logger::WARNING)
def("PushLogSink",push_log_sink); .value("Script", Logger::SCRIPT)
def("GetCurrentLogSink",get_log_sink); .value("Info", Logger::INFO)
def("PopLogSink",pop_log_sink); .value("Verbose", Logger::VERBOSE)
.value("Debug", Logger::DEBUG)
.value("Trace", Logger::TRACE)
;
def("PushVerbosityLevel", push_verb);
def("PopVerbosityLevel", pop_verb);
def("GetVerbosityLevel", get_verb);
def("PushLogSink", push_log_sink);
def("GetCurrentLogSink", get_log_sink);
def("PopLogSink", pop_log_sink);
def("LogError", raw_function(log_error, 1)); def("LogError", raw_function(log_error, 1));
def("LogWarning",raw_function(log_warning, 1)); def("LogWarning",raw_function(log_warning, 1));
def("LogInfo", raw_function(log_info, 1)); def("LogInfo", raw_function(log_info, 1));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment