Skip to content

Commit

Permalink
update readme (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija1 authored Aug 31, 2020
1 parent 66117e9 commit 9e213b3
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
**Logtron** is a simple logging library with JSON log formatting.

```python
import logtron
logger = logtron.autodiscover()
logger.info("hello world")
>>> import logtron
>>> logger = logtron.autodiscover()
>>> logger.info("hello world")
{"timestamp": 1598900664859, "message": "hello world", "name": "root", "level": 20, "context": {}, "extra": {}}
>>> logger.info("extra args", extra={"foo": "bar", "count": 7})
{"timestamp": 1598900667704, "message": "extra args", "name": "root", "level": 20, "context": {}, "extra": {"foo": "bar", "count": 7}}
>>>
```

Or

```python
import logtron
logtron.autodiscover() # Only needs to run once somewhere to configure the root logger

import logging
logger = logging.getLogger()
logger.info("hello world")
>>> import logtron
>>> logtron.autodiscover() # Only needs to run once somewhere to configure the root logger
<RootLogger root (INFO)>
>>>
>>> import logging
>>> logger = logging.getLogger()
>>> logger.info("hello world")
{"timestamp": 1598900735699, "message": "hello world", "name": "root", "level": 20, "context": {}, "extra": {}}
>>> logger.info("extra args", extra={"foo": "bar", "count": 7})
{"timestamp": 1598900757238, "message": "extra args", "name": "root", "level": 20, "context": {}, "extra": {"foo": "bar", "count": 7}}
>>>
```

Logtron allows you to skip all the usual boilerplate when configuring python logging.
Expand Down

0 comments on commit 9e213b3

Please sign in to comment.