Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
f7a49532
Commit
f7a49532
authored
5 years ago
by
Xavier Robin
Browse files
Options
Downloads
Patches
Plain Diff
doc: Document the use of LogLevel enums
parent
9b927d48
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/base/doc/logging.rst
+84
-18
84 additions, 18 deletions
modules/base/doc/logging.rst
with
84 additions
and
18 deletions
modules/base/doc/logging.rst
+
84
−
18
View file @
f7a49532
...
...
@@ -41,32 +41,44 @@ OpenStructure has a logging system going beyond what print statements can offer.
Verbosity Level
--------------------------------------------------------------------------------
Several verbosity levels are available. Verbosity levels are represented
by an enumeration of integer values. They are wrapped to objects with
memorable names by the :class:`LogLevel` class. The available levels are
are summarized in the table below.
=========== ================ ===================
Level name Verbosity value LogLevel object
=========== ================ ===================
Error 0 LogLevel.Error
Warning 1 LogLevel.Warning
Script 2 LogLevel.Script
Info 3 LogLevel.Info
Verbose 4 LogLevel.Verbose
Debug 5 LogLevel.Debug
Trace 6 LogLevel.Trace
=========== ================ ===================
You can change the verbosity level with the following two methods:
.. function:: PushVerbosityLevel(verbosity)
Change the verbosity level to the given integer value. All log events which
Change the verbosity level to the given integer value or :class:`LogLevel`
enumeration object. All log events which
have a severity above *verbosity* will not be shown. By default, the log level
is 2, meaning that errors, warnings and script logging events are visible. By
setting it to -1, you can disable all logging. The table below shows the
mapping between the verbosity level names and their numeric values:
=========== ================
Level name Verbosity value
=========== ================
(disabled) -1
Error 0
Warning 1
Script 2
Info 3
Verbose 4
Debug 5
Trace 6
=========== ================
setting it to -1, you can disable all logging.
:param verbosity: Desired verbosity level
:type verbosity: :class:`int`
.. code-block:: python
# Display warnings and errors:
ost.PushVerbosityLevel(ost.LogLevel.Warning)
# Disable all logging:
ost.PushVerbosityLevel(-1)
.. function:: PopVerbosityLevel()
Change the log level back to the previous verbosity level. It is an error to
...
...
@@ -78,11 +90,65 @@ You can change the verbosity level with the following two methods:
:return: The current verbosity level
:rtype: :class:`int`
The :class:`LogLevel` class allows to map these integer values
to more a human-readable objects
.. code-block:: python
print ost.GetVerbosityLevel()
# Outputs: 2
print ost.LogLevel.values[ost.GetVerbosityLevel()]
# Outputs: Script
.. class:: LogLevel
Enumerates the logging levels (see :ref:`picking-logging-level`). Values:
Error, Warning, Script, Info, Verbose, Debug, Trace
.. attribute:: Error, Warning, Script, Info, Verbose, Debug, Trace
The enumerated LogLevel object, which wraps the corresponding integer
value. Note that these attributes are LogLevel objects themselves.
:type: :class:`LogLevel`
.. code-block:: python
ost.LogLevel.Info
# Outputs: ost._ost_base.LogLevel.Info
print ost.LogLevel.Info
# Outputs: Info
int(ost.LogLevel.Info)
# Outputs: 3
.. attribute:: name
The name of the level
:type: :class:`str`
.. code-block:: python
ost.LogLevel.Info.name
# Outputs: 'Info'
.. attribute:: names
A dictionary mapping the log level names to the corresponding
LogLevel enumerated object.
:type: :class:`dict`
.. attribute:: values
A dictionary mapping the log level integer to the corresponding
LogLevel enumerated object.
:type: :class:`dict`
Log sinks
--------------------------------------------------------------------------------
...
...
@@ -231,4 +297,4 @@ terminal (or the python shell in DNG). The logger also prints the current time.
py_logger=PyLogger()
ost.PushLogSink(py_logger)
ost.LogInfo("amazing logging system")
\ No newline at end of file
ost.LogInfo("amazing logging system")
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment