Skip to content

Commit

Permalink
Document how to reset logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed May 3, 2020
1 parent d0d5de1 commit e9f9797
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
36 changes: 36 additions & 0 deletions docs/logging.md
@@ -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)
```
1 change: 1 addition & 0 deletions mkdocs.yml
Expand Up @@ -23,6 +23,7 @@ nav:
- Custom Types: types/custom.md
- File Formats: formats.md
- Utilities: utilities.md
- Logging: logging.md
- Settings: settings.md
- About:
- Release Notes: about/changelog.md
Expand Down
20 changes: 10 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
@@ -1,7 +1,7 @@
[tool.poetry]

name = "datafiles"
version = "0.10b1"
version = "0.10b2"
description = "File-based ORM for dataclasses."

license = "MIT"
Expand Down Expand Up @@ -52,7 +52,7 @@ parse = "^1.12"
# Utilities
cached_property = "^1.5"
classproperties = "~0.1.3"
minilog = "^1.4.1"
minilog = "^1.6b5"

# Typing
typing-extensions = "^3.7"
Expand Down

0 comments on commit e9f9797

Please sign in to comment.