Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain project #49

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test

on:
- push

jobs:
build:
name: Python ${{ matrix.python-version }} / ${{ matrix.tox-environment }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version:
- 3.8
- 3.9
tox-environment:
- django32
- django42
include:
- python-version: 3.9
- tox-environment: lint

env:
TOXENV: ${{ matrix.tox-environment }}

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install tox

- name: Run tests
run: tox
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
1.13 (unreleased)
+++++++++++++++++

- Nothing changed yet.
- Add support for Django >= 3.0
- Drop support for Django < 3.0


1.12 (2018-06-01)
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION = $(shell python setup.py --version)
UPSTREAM=git@github.com:peopledoc/pylogctx.git
UPSTREAM=git@github.com:UKGEPIC/hrsd-pylogctx.git

default:

Expand All @@ -25,4 +25,4 @@ upload:
python3 setup.py sdist bdist_wheel --universal upload -r pypi

test:
python setup.py test
pytest tests
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using ``logging``, transparently.
myticket = get_object_or_404(models.Ticket, pk=ticket_id)

# push objects, they will be adapted to log fields
log_context.update(myticket):
log_context.update(myticket)

# Log as usual
logger.info("Working on %r", myticket)
Expand Down Expand Up @@ -83,7 +83,7 @@ There is a few helpers for Celery_ and Django_ projects. See USAGE_ for details!
Contributors
============

Join us to make log rocking better! Read HACKING_ and ask maintainers:
Join us to make log rocking better! Read HACKING_ and ask authors:

* David STEINBERGER `@dsteinberger <https://github.com/dsteinberger>`_
* Étienne BERSAC `@bersace <https://github.com/bersace>`_
Expand Down
71 changes: 71 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[build-system]
requires = ["setuptools >= 61", "setuptools-scm"]
build-backend = "setuptools.build_meta"


[project]
name = "pylogctx"
description = "Adding context to log records"
readme = "README.rst"
requires-python = ">=3.8"
license = {file = "LICENSE"}
authors = [
{name = "Lev Orekhov", email = "lev.orekhov@gmail.com"},
{name = "Cross Capabilities"},
]
maintainers = [
{name = "Cross Capabilities"}
]
keywords = []
classifiers = [
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"django",
"celery",
]
dynamic = ["version"]

[project.optional-dependencies]
lint = [
"black",
"ruff",
]
test = [
"pytest",
"pytest-cov",
"pytest-mock",
"pytest-django",
"coverage",
]
tox = [
"tox",
]

[project.urls]
repository = "https://github.com/UKGEPIC/hrsd-pylogctx"

[tool.black]
line-length = 79

[tool.setuptools]
zip-safe = false

[tool.setuptools.dynamic]
version = {attr = "pylogctx.__version__"}

[tool.zest-releaser]
python-file-with-version = "src/pylogctx/__init__.py"

[tool.pytest.ini_options]
addopts = " --cov-config=pyproject.toml --cov=pylogctx --disable-pytest-warnings"

[tool.coverage.report]
show_missing = true
64 changes: 0 additions & 64 deletions setup.py

This file was deleted.

16 changes: 9 additions & 7 deletions src/pylogctx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
)

__all__ = [
'AdapterNotFound',
'AddContextFilter',
'AddContextFormatter',
'ExcInfoFilter',
'LazyAccessor',
'context',
'log_adapter',
"AdapterNotFound",
"AddContextFilter",
"AddContextFormatter",
"ExcInfoFilter",
"LazyAccessor",
"context",
"log_adapter",
]

__version__ = "1.13.dev0"
22 changes: 12 additions & 10 deletions src/pylogctx/celery.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
from __future__ import absolute_import

import logging
import warnings
from inspect import getfullargspec

from celery import current_task
from celery import Task

from .compat import getargspec
from .core import context


logger = logging.getLogger(__name__)


class LoggingTask(Task):

def before_call(self, *args, **kwargs):
# Override if you need to add some vars or log something.
pass
Expand All @@ -29,10 +26,12 @@ def __call__(self, *args, **kwargs):
self.save_context = context.as_dict()
context.clear()

arg_spec = getargspec(self.before_call)
arg_spec = getfullargspec(self.before_call)
if arg_spec.varargs is None:
# To keep breaking compat
warnings.warn('Method `before_call` without args is deprecated')
warnings.warn(
"Method `before_call` without args is deprecated", stacklevel=1
)
self.before_call()
else:
self.before_call(*args, **kwargs)
Expand All @@ -42,15 +41,18 @@ def __call__(self, *args, **kwargs):
try:
context.update(task)
except Exception as e:
logger.debug('Failed to push task to log context: %r', e)
logger.debug("Failed to push task to log context: %r", e)

try:
return super(LoggingTask, self).__call__(*args, **kwargs)
return super().__call__(*args, **kwargs)
finally:
arg_spec = getargspec(self.after_call)
arg_spec = getfullargspec(self.after_call)
if arg_spec.varargs is None:
# To keep breaking compat
warnings.warn('Method `after_call` without args is deprecated')
warnings.warn(
"Method `after_call` without args is deprecated",
stacklevel=1,
)
self.after_call()
else:
self.after_call(*args, **kwargs)
Expand Down
10 changes: 0 additions & 10 deletions src/pylogctx/compat.py

This file was deleted.

Loading
Loading