Skip to content

Commit 34661fa

Browse files
committed
Update documentation
1 parent 2671307 commit 34661fa

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
# Python Logfmter
1+
![python logfmter](./banner.png)
2+
3+
<div align="center">
24

35
[![pre-commit](https://github.com/jteppinette/python-logfmter/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/jteppinette/python-logfmter/actions/workflows/pre-commit.yml)
46
[![test](https://github.com/jteppinette/python-logfmter/actions/workflows/test.yml/badge.svg)](https://github.com/jteppinette/python-logfmter/actions/workflows/test.yml)
57
[![python-3.9-3.10-3.11-3.12](https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11|%203.12-blue.svg)](.github/workflows/test.yml)
68

7-
Using the stdlib logging module and without changing a single logging call, logfmter supports
8-
**global** (first and third party) [logfmt](https://www.brandur.org/logfmt) structured logging.
9+
Add [logfmt](https://www.brandur.org/logfmt) structured logging using the stdlib logging module and without changing a single log call.
10+
11+
</div>
912

1013
```python
1114
> logging.warn("user created", extra=user)
1215

1316
at=WARNING msg="user created" first_name=John last_name=Doe age=25
1417
```
1518

16-
## Table of Contents
19+
# Table of Contents
1720

1821
1. [Why](#why)
1922
2. [Install](#install)
@@ -27,24 +30,24 @@ at=WARNING msg="user created" first_name=John last_name=Doe age=25
2730
2. [Getting Started](#getting-started)
2831
3. [Publishing](#publishing)
2932

30-
## Why
33+
# Why
3134

3235
- enables both human and computer readable logs, [recommended as a "best practice" by Splunk](https://dev.splunk.com/enterprise/docs/developapps/addsupport/logging/loggingbestpractices/)
3336
- formats all first and third party logs, you never have to worry about a library using a different logging format
3437
- simple to integrate into any existing application, requires no changes to existing log statements i.e. [structlog](https://github.com/hynek/structlog)
3538

36-
## Install
39+
# Install
3740

3841
```sh
3942
$ pip install logfmter
4043
```
4144

42-
## Usage
45+
# Usage
4346

4447
This package exposes a single `Logfmter` class that can be integrated into
4548
the [standard library logging system](https://docs.python.org/3/howto/logging.html) like any [`logging.Formatter`](https://docs.python.org/3/howto/logging.html#formatters).
4649

47-
### Integration
50+
## Integration
4851

4952
**[basicConfig](https://docs.python.org/3/library/logging.html#logging.basicConfig)**
5053

@@ -107,7 +110,7 @@ items after `"()"`:_
107110

108111
Using logfmter via fileConfig is not supported, because fileConfig does not support custom formatter initialization. There may be some hacks to make this work in the future. Let me know if you have ideas or really need this.
109112

110-
### Configuration
113+
## Configuration
111114

112115
**keys**
113116

@@ -179,7 +182,7 @@ logging.basicConfig(handlers=[handler])
179182
logging.error("hello") # at=ERROR when=2022-04-20 msg=hello
180183
```
181184

182-
### Extension
185+
## Extension
183186

184187
You can subclass the formatter to change its behavior.
185188

@@ -209,7 +212,7 @@ logging.basicConfig(handlers=[handler])
209212
logging.error({"example": True}) # at=ERROR example=yes
210213
```
211214

212-
### Guides
215+
## Guides
213216

214217
**Default Key/Value Pairs**
215218

@@ -230,17 +233,17 @@ logging.setLogRecordFactory(record_factory)
230233
This will cause all logs to have the `trace_id=123` pair regardless of including
231234
`trace_id` in keys or manually adding `trace_id` to the `extra` parameter or the `msg` object.
232235

233-
## Development
236+
# Development
234237

235-
### Required Software
238+
## Required Software
236239

237240
If you are using [nix](https://zero-to-nix.com/start/install/) & [direnv](https://direnv.net/docs/installation.html), then your dev environment will be managed automatically. Otherwise, you will need to manually install the following software:
238241

239242
- [direnv](https://direnv.net)
240243
- [git](https://git-scm.com/)
241244
- [pyenv](https://github.com/pyenv/pyenv#installation)
242245

243-
### Getting Started
246+
## Getting Started
244247

245248
**Setup**
246249

@@ -274,7 +277,7 @@ _Run the test suite against all supported python versions._
274277
$ tox
275278
```
276279

277-
### Publishing
280+
## Publishing
278281

279282
**Create**
280283

banner.png

1.11 MB
Loading

0 commit comments

Comments
 (0)