Skip to content

Commit 8f6952a

Browse files
committed
logging docu & logger_config() rename
1 parent 14b1eb5 commit 8f6952a

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dataClay
1212
advanced-usage
1313
telemetry
1414
hpc-tracing
15+
logging
1516
examples/index
1617

1718
.. toctree::

docs/logging.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
=======
2+
Logging
3+
=======
4+
5+
DataClay offers logging to allow code debugging and information collection.
6+
7+
When dataclay is imported, the logging is first initialized with a basic configuration in the config.py file:
8+
9+
.. code-block:: python
10+
:caption: config.py
11+
12+
...
13+
14+
class Settings(BaseSettings):
15+
16+
...
17+
18+
loglevel: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=True)] = "INFO"
19+
20+
...
21+
22+
settings = Settings()
23+
24+
...
25+
26+
27+
def logger_config(**kwargs):
28+
logging.basicConfig(**kwargs)
29+
30+
31+
logger_config(level=settings.loglevel)
32+
33+
34+
35+
If the user wants to configure its own logging, it can be done by importing the logging library and modifying
36+
the basicConfig. When client.start() function is called, then logger_config() is executed again, and if the argument
37+
"force" is True then the logging configuration is overwritten.
38+
39+
.. warning::
40+
When modifying the basicConfig remember that the **force=True** parameter is mandatory. Otherwise, this new
41+
configuration will be obviated.
42+
43+
An example is available in `GitHub <https://github.com/bsc-dom/dataclay/tree/main/examples/client-logger-config>`_

src/dataclay/client/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from dataclay.config import (
1919
ClientSettings,
2020
get_runtime,
21-
loggerConfig,
21+
logger_config,
2222
session_var,
2323
set_runtime,
2424
settings,
@@ -170,7 +170,7 @@ def __init__(
170170
def start(self):
171171
"""Start the client runtime"""
172172

173-
loggerConfig(level=settings.loglevel)
173+
logger_config(level=settings.loglevel)
174174

175175
if self.is_active:
176176
logger.warning("Client already active. Ignoring")

src/dataclay/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ def set_runtime(new_runtime: Union[ClientRuntime, BackendRuntime]):
232232
current_runtime = new_runtime
233233

234234

235-
def loggerConfig(**kwargs):
235+
def logger_config(**kwargs):
236236
logging.basicConfig(**kwargs)
237237

238238

239-
loggerConfig(level=settings.loglevel)
239+
logger_config(level=settings.loglevel)

0 commit comments

Comments
 (0)