Skip to content

Commit b88db68

Browse files
committed
chore: rename project to logging-with-context
Trying to dodge this error: The name 'contextual-logging' is too similar to an existing project. See https://pypi.org/help/#project-name for more information.
1 parent 97fc909 commit b88db68

13 files changed

Lines changed: 47 additions & 39 deletions

File tree

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Contextual logging
1+
# Logging with context (contextual logging)
22

33
This library provides utilities to easily add context to logging messages and to show them.
44

@@ -23,6 +23,14 @@ This library provides utilities and logging abstractions to ease the use of this
2323
Python 3.9 or greater
2424

2525

26+
## Install
27+
28+
Install the package [logging-with-context](pypi.org/project/logging-with-context).
29+
30+
> [!NOTE]
31+
> The package is named logging-with-context because contextual-logging was rejected by Pypi due to being too similar to an existing project.
32+
33+
2634
## How to use it
2735

2836
The expected workflow is:
@@ -40,7 +48,7 @@ After configuring your application's logging, initialize the global context:
4048
```python
4149
import logging
4250

43-
from contextual_logging.global_context import global_context_initialized
51+
from logging_with_context.global_context import global_context_initialized
4452

4553

4654
def main():
@@ -56,7 +64,7 @@ It accepts a dictionary with the values you want to include in all the logging m
5664
```python
5765
import logging
5866

59-
from contextual_logging.global_context import add_global_context
67+
from logging_with_context.global_context import add_global_context
6068

6169

6270
# ... somewhere in your app ...
@@ -77,7 +85,7 @@ In case you can't use the context manager, you can use the manual initialization
7785
```python
7886
import logging
7987

80-
from contextual_logging.global_context import init_global_context, shutdown_global_context
88+
from logging_with_context.global_context import init_global_context, shutdown_global_context
8189

8290

8391
def main():
@@ -109,7 +117,7 @@ To show the context you need a `Formatter` that somehow uses the context in the
109117

110118
For example, the logging handler in Python applications running at AWS Lambda handles this automatically by adding the context provided in `extra` as labels to the log struct, separated from the message.
111119

112-
If you're logging to a `StreamHandler` you can use `contextual_logging.formatters.ExtraTextFormatter`, which accepts the same options as the standard library `Formatter`.
120+
If you're logging to a `StreamHandler` you can use `logging_with_context.formatters.ExtraTextFormatter`, which accepts the same options as the standard library `Formatter`.
113121

114122
You can use it instead of the default `Formatter` in your logging setup:
115123

@@ -118,7 +126,7 @@ version: 1
118126

119127
formatters:
120128
contextual:
121-
class: contextual_logging.formatters.ExtraTextFormatter
129+
class: logging_with_context.formatters.ExtraTextFormatter
122130
format: '%(levelname)s %(message)s'
123131

124132
handlers:
@@ -137,7 +145,7 @@ If you're modifying the logging setup made by other part of an application, you
137145
```python
138146
import logging
139147
140-
from contextual_logging.formatters import ExtraTextFormatter
148+
from logging_with_context.formatters import ExtraTextFormatter
141149
142150
def main():
143151
logging.basicConfig(level=logging.INFO)
@@ -161,7 +169,7 @@ The API accepts a list of loggers where the `Filter` will be attached in these c
161169
```python
162170
import logging
163171
164-
from contextual_logging.global_context import global_context_initialized
172+
from logging_with_context.global_context import global_context_initialized
165173
166174
167175
def app_entrypoint():

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "contextual-logging"
2+
name = "logging-with-context"
33
description = "Python library to add context to logging messages"
44
readme = "README.md"
55
authors = [
@@ -44,7 +44,7 @@ select = [
4444
split-on-trailing-comma = false
4545

4646
[tool.pytest.ini_options]
47-
addopts = "--cov-report term --cov-report html --cov contextual_logging"
47+
addopts = "--cov-report term --cov-report html --cov logging_with_context"
4848

4949
[tool.coverage.run]
5050
branch = true
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class ContextualAdapter(LoggerAdapter):
1818
Set up everything
1919
2020
>>> import logging
21-
>>> from contextual_logging.adapters import ContextualAdapter
22-
>>> from contextual_logging.formatters import ExtraTextFormatter
21+
>>> from logging_with_context.adapters import ContextualAdapter
22+
>>> from logging_with_context.formatters import ExtraTextFormatter
2323
>>> logging.basicConfig(level=logging.INFO)
2424
>>> root = logging.getLogger()
2525
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(
7777
For example:
7878
7979
>>> import logging
80-
>>> from contextual_logging.formatters import ExtraTextFormatter
80+
>>> from logging_with_context.formatters import ExtraTextFormatter
8181
>>> logging.basicConfig(level=logging.INFO)
8282
>>> for handler in logging.getLogger().handlers:
8383
>>> handler.setFormatter(ExtraTextFormatter(

src/contextual_logging/global_context.py renamed to src/logging_with_context/global_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from logging import Logger, getLogger
1111
from typing import Any, Generator, Optional, Sequence
1212

13-
from contextual_logging.filters import FilterWithContextVar
13+
from logging_with_context.filters import FilterWithContextVar
1414

1515
# NOTE: ContextVar should be created at the top module level.
1616
__global_context_var: ContextVar[dict[str, Any]] = ContextVar(

tests/contextual_logging/test_adapters.py renamed to tests/logging_with_context/test_adapters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from pytest import LogCaptureFixture
44

5-
from contextual_logging.adapters import ContextualAdapter
5+
from logging_with_context.adapters import ContextualAdapter
66

77

88
def test_contextual_adapter_with_extras_ok(caplog: LogCaptureFixture):

0 commit comments

Comments
 (0)