Skip to content

Commit

Permalink
Remove old logger from docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dostuffthatmatters committed Jan 21, 2025
1 parent 8e78888 commit e5ba3e5
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions docs/pages/example-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,70 +120,6 @@ replacements = {
filled_template = insert_replacements(template, replacements)
```

## Custom Logger

We found the `logging` module from the standard Python library hard to configure when other subprojects or libraries also use it. Additionally, we wanted to have an automatic archiving functionality.

Hence, this class is a simple reimplementation of the logging module's core features.

```python
from tum_esm_utils.logger import Logger

my_logger = Logger(
origin = "my_logger",
logfile_directory = "/tmp/logs"
)
```

The log lines of the last hour can be found in `/tmp/logs/current-logs.log`. All older log lines can be found in `/tmp/logs/archive/YYYYMMDD.log` (`/tmp ...` is used in the example code above).

Regular log lines (debug, info, warning, error):

```python
my_logger.debug("hello")
my_logger.info("hello")
my_logger.warning("hello")
my_logger.error("hello")
```

```log
time UTC±X - origin - level - message
```

You can give the more details to each log type:

```python
my_logger.debug("hello", details="some elaborate details on what happened")
```

```log
time UTC±X - origin - DEBUG - hello
--- details: ---------------------------
some elaborate details on what happened
----------------------------------------
```

Exception logging:

```python
try:
30 / 0
except Exception:
my_logger.exception(
label="custom label",
details="some elaborate details on what happened"
)
```

```log
time UTC±X - origin - EXCEPTION - custom label, ZeroDivisionError: division by zero
--- details: ---------------------------
some elaborate details on what happened
--- traceback: -------------------------
...
----------------------------------------
```

## Strict Path Validation with Pydantic

Pydantic has a lot of field validators (number must be greater equal, etc.),
Expand Down

0 comments on commit e5ba3e5

Please sign in to comment.