Skip to content

Commit 1ab0ce9

Browse files
authored
Merge pull request #12 from Colin-b/develop
Release 0.4.0
2 parents abf957c + 0f30296 commit 1ab0ce9

10 files changed

Lines changed: 39 additions & 31 deletions

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
14+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
1515

1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v3
1818
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v2
19+
uses: actions/setup-python@v4
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222
- name: Install dependencies

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
11+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v2
16+
uses: actions/setup-python@v4
1717
with:
1818
python-version: ${{ matrix.python-version }}
1919
- name: Install dependencies

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 22.10.0
3+
rev: 22.12.0
44
hooks:
55
- id: black

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.4.0] - 2023-01-09
10+
### Changed
11+
- Default message key is now `message` instead of `msg` to stay in line with python default. If you still want previous behavior, set `message_field_name` to `msg` at formatter creation.
12+
13+
### Removed
14+
- Drop support for python 3.6.
15+
916
## [0.3.0] - 2022-12-02
1017
### Added
1118
- Added `exception_field_name` parameter.
@@ -27,7 +34,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2734
### Added
2835
- Public release.
2936

30-
[Unreleased]: https://github.com/Colin-b/logging_json/compare/v0.3.0...HEAD
37+
[Unreleased]: https://github.com/Colin-b/logging_json/compare/v0.4.0...HEAD
38+
[0.4.0]: https://github.com/Colin-b/logging_json/compare/v0.3.0...v0.4.0
3139
[0.3.0]: https://github.com/Colin-b/logging_json/compare/v0.2.1...v0.3.0
3240
[0.2.1]: https://github.com/Colin-b/logging_json/compare/v0.2.0...v0.2.1
3341
[0.2.0]: https://github.com/Colin-b/logging_json/compare/v0.1.0...v0.2.0

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Colin Bounouar
3+
Copyright (c) 2023 Colin Bounouar
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<a href="https://github.com/Colin-b/logging_json/actions"><img alt="Build status" src="https://github.com/Colin-b/logging_json/workflows/Release/badge.svg"></a>
66
<a href="https://github.com/Colin-b/logging_json/actions"><img alt="Coverage" src="https://img.shields.io/badge/coverage-100%25-brightgreen"></a>
77
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
8-
<a href="https://github.com/Colin-b/logging_json/actions"><img alt="Number of tests" src="https://img.shields.io/badge/tests-18 passed-blue"></a>
8+
<a href="https://github.com/Colin-b/logging_json/actions"><img alt="Number of tests" src="https://img.shields.io/badge/tests-21 passed-blue"></a>
99
<a href="https://pypi.org/project/logging_json/"><img alt="Number of downloads" src="https://img.shields.io/pypi/dm/logging_json"></a>
1010
</p>
1111

@@ -57,9 +57,9 @@ The resulting JSON dictionary will be the one you provided (with the [additional
5757

5858
### Logging with anything else (such as a string)
5959

60-
Anything not logged using a dictionary will be handled by the standard formatter and it can result in one of the 2 output:
61-
* A JSON dictionary, if [additional fields](#adding-additional-fields-and-values) are set or if `extra` parameter is used while logging, with the message available in the `msg` key of the resulting JSON dictionary.
62-
Default `msg` key name can be changed by `message_field_name` parameter of the `logging_json.JSONFormatter` instance.
60+
Anything not logged using a dictionary will be handled by the standard formatter, and it can result in one of the 2 output:
61+
* A JSON dictionary, if [additional fields](#adding-additional-fields-and-values) are set or if `extra` parameter is used while logging, with the message available in the `message` key of the resulting JSON dictionary.
62+
Default `message` key name can be changed by `message_field_name` parameter of the `logging_json.JSONFormatter` instance.
6363
* The formatted record, if no [additional fields](#adding-additional-fields-and-values) are set.
6464

6565
This handles the usual string logging as in the following:
@@ -72,7 +72,7 @@ logging.info("This is my message")
7272

7373
## Configuration
7474

75-
You can create a formatter instance yourself as in the following or you can use a logging configuration.
75+
You can create a formatter instance yourself as in the following, or you can use a logging configuration.
7676

7777
```python
7878
import logging_json
@@ -159,7 +159,7 @@ root:
159159
```
160160
161161
## How to install
162-
1. [python 3.6+](https://www.python.org/downloads/) must be installed
162+
1. [python 3.7+](https://www.python.org/downloads/) must be installed
163163
2. Use pip to install module:
164164
```sh
165165
python -m pip install logging_json

logging_json/_formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __init__(
6060
self,
6161
*args,
6262
fields: Dict[str, Any] = None,
63-
message_field_name: str = "msg",
63+
message_field_name: str = "message",
6464
exception_field_name: Optional[str] = "exception",
6565
**kwargs,
6666
):

logging_json/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# Major should be incremented in case there is a breaking change. (eg: 2.5.8 -> 3.0.0)
44
# Minor should be incremented in case there is an enhancement. (eg: 2.5.8 -> 2.6.0)
55
# Patch should be incremented in case there is a bug fix. (eg: 2.5.8 -> 2.5.9)
6-
__version__ = "0.3.0"
6+
__version__ = "0.4.0"

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
"Natural Language :: English",
2626
"Programming Language :: Python",
2727
"Programming Language :: Python :: 3",
28-
"Programming Language :: Python :: 3.6",
2928
"Programming Language :: Python :: 3.7",
3029
"Programming Language :: Python :: 3.8",
3130
"Programming Language :: Python :: 3.9",
3231
"Programming Language :: Python :: 3.10",
32+
"Programming Language :: Python :: 3.11",
3333
"Topic :: Software Development :: Build Tools",
3434
],
3535
keywords=["logging", "json"],
@@ -38,10 +38,10 @@
3838
extras_require={
3939
"testing": [
4040
# Used to check coverage
41-
"pytest-cov==3.*",
41+
"pytest-cov==4.*",
4242
]
4343
},
44-
python_requires=">=3.6",
44+
python_requires=">=3.7",
4545
project_urls={
4646
"GitHub": "https://github.com/Colin-b/logging_json",
4747
"Changelog": "https://github.com/Colin-b/logging_json/blob/master/CHANGELOG.md",

tests/test_formatter.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,27 @@ def test_str_with_args_message(caplog):
3939
def test_str_with_message_field_name(caplog):
4040
caplog.set_level("INFO")
4141
logging.info("message 1")
42-
assert fmt(caplog, message_field_name="message") == "message 1"
42+
assert fmt(caplog, message_field_name="msg") == "message 1"
4343

4444

4545
def test_str_with_extra_message(caplog):
4646
caplog.set_level("INFO")
4747
logging.info("message 1", extra={"key1": "value 1"})
48-
assert dict_fmt(caplog) == {"msg": "message 1", "key1": "value 1"}
48+
assert dict_fmt(caplog) == {"message": "message 1", "key1": "value 1"}
4949

5050

5151
def test_str_with_message_field_name_and_fields(caplog):
5252
caplog.set_level("INFO")
5353
logging.info("message 1")
5454
assert dict_fmt(
55-
caplog, message_field_name="message", fields={"level": "levelname"}
56-
) == {"message": "message 1", "level": "INFO"}
55+
caplog, message_field_name="msg", fields={"level": "levelname"}
56+
) == {"msg": "message 1", "level": "INFO"}
5757

5858

5959
def test_str_with_args_and_extra_message(caplog):
6060
caplog.set_level("INFO")
6161
logging.info("message %s", "1", extra={"key1": "value 1"})
62-
assert dict_fmt(caplog) == {"msg": "message 1", "key1": "value 1"}
62+
assert dict_fmt(caplog) == {"message": "message 1", "key1": "value 1"}
6363

6464

6565
def test_dict_message_with_asctime(caplog, monkeypatch):
@@ -77,7 +77,7 @@ def test_str_message_with_asctime(caplog, monkeypatch):
7777
logging.info("message 1")
7878
actual = dict_fmt(caplog, fields={"date_time": "asctime"})
7979
assert time.strptime(actual.pop("date_time"), "%Y-%m-%d %H:%M:%S,007")
80-
assert actual == {"msg": "message 1"}
80+
assert actual == {"message": "message 1"}
8181

8282

8383
def test_str_with_args_message_with_asctime(caplog, monkeypatch):
@@ -86,7 +86,7 @@ def test_str_with_args_message_with_asctime(caplog, monkeypatch):
8686
logging.info("message %s", "1")
8787
actual = dict_fmt(caplog, fields={"date_time": "asctime"})
8888
assert time.strptime(actual.pop("date_time"), "%Y-%m-%d %H:%M:%S,007")
89-
assert actual == {"msg": "message 1"}
89+
assert actual == {"message": "message 1"}
9090

9191

9292
def test_str_with_args_and_extra_message_with_asctime(caplog, monkeypatch):
@@ -95,7 +95,7 @@ def test_str_with_args_and_extra_message_with_asctime(caplog, monkeypatch):
9595
logging.info("message %s", "1", extra={"key1": "value 1"})
9696
actual = dict_fmt(caplog, fields={"date_time": "asctime"})
9797
assert time.strptime(actual.pop("date_time"), "%Y-%m-%d %H:%M:%S,007")
98-
assert actual == {"msg": "message 1", "key1": "value 1"}
98+
assert actual == {"message": "message 1", "key1": "value 1"}
9999

100100

101101
def test_dict_message_at_exception_level(caplog):
@@ -157,7 +157,7 @@ def test_str_message_at_exception_level(caplog):
157157
actual = dict_fmt(caplog)
158158
actual["exception"].pop("stack")
159159
assert actual == {
160-
"msg": "message 1",
160+
"message": "message 1",
161161
"exception": {
162162
"message": "this is the exception message",
163163
"type": "MyException",
@@ -174,7 +174,7 @@ def test_str_with_args_message_at_exception_level(caplog):
174174
actual = dict_fmt(caplog)
175175
actual["exception"].pop("stack")
176176
assert actual == {
177-
"msg": "message 1",
177+
"message": "message 1",
178178
"exception": {
179179
"message": "this is the exception message",
180180
"type": "MyException",
@@ -237,7 +237,7 @@ def test_with_extra_in_fields_and_message(caplog):
237237
"extra": "value 1",
238238
"key1": "value 1",
239239
"key2": "value 2",
240-
"msg": "message 1",
240+
"message": "message 1",
241241
}
242242

243243

0 commit comments

Comments
 (0)