Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0d5de1
commit e9f9797
Showing
4 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<h1>Logging</h1> | ||
|
||
Logging is managed by [`minilog`](https://minilog.readthedocs.io), which configures logging automatically. Because the `@datafile()` decorator runs code at the module level, `datafiles` may prematurely configure logging for your application. | ||
|
||
# Silence | ||
|
||
To suppress this behavior, you should silence the `datafiles` logger before any models are defined: | ||
|
||
```python hl_lines="4" | ||
from datafiles import datafile | ||
import log | ||
|
||
log.silence('datafiles') | ||
|
||
@datafile("inventory/items/{self.name}.yml") | ||
class InventoryItem: | ||
|
||
name: str | ||
unit_price: float | ||
quantity_on_hand: int = 0 | ||
|
||
``` | ||
|
||
# Reset | ||
|
||
If that's insufficient, you can reset logging back to its initial state after more models are defined: | ||
|
||
```python hl_lines="6" | ||
import log | ||
|
||
from .models import InventoryItem | ||
|
||
def main(): | ||
log.reset() | ||
item = InventoryItem.objects.create("widget", 0.99) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters