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/getting-started.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,14 +31,21 @@ As a result, the simplest possible usage looks like this:
31
31
Here, *structlog* takes advantage of its default settings:
32
32
33
33
- Output is sent to **[standard out](https://en.wikipedia.org/wiki/Standard_out#Standard_output_.28stdout.29)** instead of doing nothing.
34
+
34
35
- It **imitates** standard library {mod}`logging`'s **log level names** for familiarity.
35
36
By default, no level-based filtering is done, but it comes with a **very fast [filtering machinery](filtering)**.
37
+
36
38
- Like in `logging`, positional arguments are [**interpolated into the message string using %**](https://docs.python.org/3/library/stdtypes.html#old-string-formatting).
37
39
That might look dated, but it's *much* faster than using {any}`str.format` and allows *structlog* to be used as drop-in replacement for {mod}`logging`.
38
40
If you *know* that the log entry is *always* gonna be logged out, just use [f-strings](https://docs.python.org/3/tutorial/inputoutput.html#formatted-string-literals) which are the fastest.
41
+
42
+
*structlog* supports both positional and dict-based interpolation, therefore `log.info("hello %(name)s!", {"name": "world"})` generates the same output as above.
43
+
39
44
- All keywords are formatted using {class}`structlog.dev.ConsoleRenderer`.
40
45
That in turn uses {func}`repr` to serialize **any value to a string**.
46
+
41
47
- It's rendered in nice **{doc}`colors <console-output>`**.
48
+
42
49
- If you have [Rich] or [*better-exceptions*] installed, **exceptions** will be rendered in **colors** and with additional **helpful information**.
43
50
44
51
Please note that even in most complex logging setups the example would still look just like that thanks to {doc}`configuration`.
Since log entries are dictionaries, you can start binding and re-binding key-value pairs to your loggers to ensure they are present in every following logging call:
0 commit comments