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: docs/tutorial.md
+16-14Lines changed: 16 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,13 @@
1
1
# Getting Started with Logging in DUNE-DAQ
2
2
3
-
This is a very quick tutorial for someone entirely new to logging.
4
-
5
-
**NEED TO WRITE THE TUTORIAL HEREE**. still a wip
6
-
7
-
<!-- YOU SHOULD WRITE A BRIEF INTRO HERE: one paragraph orienting a brand new user to what they will accomplish by the end of this tutorial (e.g. "By the end of this page you will have a working logger printing coloured output to your terminal"). Keep it concrete and task-focused. -->
3
+
By the end of this tutorial you will have a working logger printing colour-formatted output to your terminal. It should take about five minutes. No prior knowledge of Python logging is assumed — if you want to understand the concepts behind what you're doing, read [Concepts & explanation](./explanation.md) afterwards.
8
4
9
5
## Prerequisites
10
6
11
-
<!-- YOU SHOULD WRITE ABOUT: what the reader needs before starting — DUNE environment loaded, daqpytools installed, etc. -->
7
+
Before starting, make sure you have:
8
+
9
+
- The DUNE DAQ environment loaded (i.e. `dbt-setup-env` or equivalent has been run in your shell)
10
+
-`daqpytools` installed in your environment
12
11
13
12
## Step 1: Initialize a logger
14
13
@@ -29,6 +28,8 @@ test_logger = get_daq_logger(
29
28
30
29
For now, **please see the docstring of `get_daq_logger` to see what stuff you can have and what to initialise with.**
31
30
31
+
This gives you a named logger with a single Rich handler attached, emitting at `INFO` level and above. Loggers in daqpytools are singletons — calling `get_daq_logger` with the same name twice will return the same instance, so it's safe to call this once at module level and reuse it throughout your code.
32
+
32
33
## Step 2: Emit your first messages
33
34
34
35
```python
@@ -43,19 +44,20 @@ test_logger.info(
43
44
)
44
45
```
45
46
46
-
## Step 3: Explore with the logging demonstrator
47
+
You should see colour-formatted output in your terminal, something like this:
47
48
48
-
A lot of the available features can be demonstrated via the logging demonstrator functionality. With the DUNE environments loaded, simply run:
49
-
50
-
```
51
-
daqpytools-logging-demonstrator
52
-
```
49
+

53
50
54
-
and view the help string to learn more, and view the script itself in the repository to see how it is implemented.
51
+
The Rich handler supports the full [Rich markup syntax](https://rich.readthedocs.io/en/stable/markup.html) inline in your log messages.
55
52
56
53
## Next steps
57
54
55
+
- To explore the full range of available handlers and filters interactively, run the logging demonstrator with the DUNE environments loaded:
56
+
```
57
+
daqpytools-logging-demonstrator
58
+
```
59
+
View the help string to learn more, and the script itself in the repository to see how it is implemented.
58
60
- To understand *why* logging works the way it does, read the [Concepts & explanation](./explanation.md).
59
61
- To learn how to use specific handlers and filters, see the [How-to guides](./how-to/).
60
-
- For a full API reference, see the [Reference](./reference/).
62
+
- For a full API reference, see the [API Ref](https://dune-daq.github.io/daqpytools/APIref).
61
63
- If you are introducing logging to your Python repo, or upgrading an existing implementation, **please** read the [Logging best practices](./how-to/best-practices.md).
0 commit comments