You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ansys/mapdl/core/logging.py
+63-49Lines changed: 63 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -1,117 +1,120 @@
1
1
"""
2
-
``log`` module
3
-
*******************
2
+
``logging`` module
3
+
**************
4
4
5
5
## Objective
6
-
This module intends to create a general framework for logging in Pymapdl.
7
-
This module is built upon ``logging`` library and it does NOT intend to replace it rather provide a way to interact between ``logging`` and ``Pymapdl``.
6
+
This module intends to create a general framework for logging in
7
+
Pymapdl. This module is built upon ``logging`` library and it does
8
+
NOT intend to replace it rather provide a way to interact between
9
+
``logging`` and ``Pymapdl``.
8
10
9
-
The loggers used in the module include the name of the instance which is intended to be unique.
10
-
This name is printed in all the active outputs and it is used to track the different MAPDL instances.
11
+
The loggers used in the module include the name of the instance which
12
+
is intended to be unique. This name is printed in all the active
13
+
outputs and it is used to track the different MAPDL instances.
11
14
12
15
13
16
Usage
14
-
----------
17
+
-----
15
18
16
19
Global logger
17
20
~~~~~~~~~~~~~~~~~
18
21
19
-
There is a global logger named ``pymapdl_global`` which is created at ``ansys.mapdl.core.__init__``.
20
-
If you want to use this global logger, you must call at the top of your module:
22
+
There is a global logger named ``pymapdl_global`` which is created at
23
+
``ansys.mapdl.core.__init__``. If you want to use this global logger,
24
+
you must call at the top of your module:
21
25
22
-
.. code::
26
+
.. code:: python
23
27
from ansys.mapdl.core import LOG
24
28
25
29
You could also rename it to avoid conflicts with other loggers (if any):
26
30
27
-
.. code::
31
+
.. code:: python
28
32
from ansys.mapdl.core import LOG as logger
29
33
30
34
31
35
It should be noticed that the default logging level of ``LOG`` is ``ERROR``.
32
36
To change this and output lower level messages you can use the next snippet:
33
37
34
-
.. code::
38
+
.. code:: python
35
39
LOG.logger.setLevel('DEBUG')
36
40
LOG.file_handler.setLevel('DEBUG') # If present.
37
41
LOG.stdout_handler.setLevel('DEBUG') # If present.
38
42
39
43
40
44
Alternatively, you can do:
41
45
42
-
.. code::
46
+
.. code:: python
43
47
LOG.setLevel('DEBUG')
44
48
45
49
46
50
This way ensures all the handlers are set to the input log level.
47
51
48
-
By default, this logger does not log to a file. If you wish to do so, you can add a file handler using:
52
+
By default, this logger does not log to a file. If you wish to do so,
0 commit comments