Skip to content

Commit

Permalink
Merge pull request #67 from resurfaceio/v3.0.x
Browse files Browse the repository at this point in the history
Stable changes for V3.0
  • Loading branch information
Anyesh authored Feb 14, 2022
2 parents d06ece1 + 60de876 commit ba89843
Show file tree
Hide file tree
Showing 26 changed files with 279 additions and 146 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
USAGE_LOGGERS_DISABLE=False
USAGE_LOGGERS_URL="http://localhost:7701/message"
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
USAGE_LOGGERS_DISABLE=False
USAGE_LOGGERS_URL="http://localhost:4001/message"
USAGE_LOGGERS_URL="http://localhost:7701/message"
26 changes: 26 additions & 0 deletions .github/workflows/crossplatform_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Crossplatform Tests

on:
- push
- pull_request

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: tox
27 changes: 0 additions & 27 deletions .github/workflows/pytest.yml

This file was deleted.

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ pip3 install --upgrade usagelogger

```python
from aiohttp import web
from usagelogger.aiohttp import HttpLoggerForAIOHTTP
from usagelogger.middleware.aiohttp import HttpLoggerForAIOHTTP

async def test(request):
return web.Response(text="Hello")

app = web.Application(
middlewares=[
HttpLoggerForAIOHTTP(
url="http://localhost:4001/message", rules="include debug"
url="http://localhost:7701/message", rules="include debug"
)
]
)
Expand All @@ -66,7 +66,7 @@ First edit `settings.py` to register middleware, like this:

```python
MIDDLEWARE = [
"usagelogger.django.HttpLoggerForDjango", # Always on the top
"usagelogger.middleware.django.HttpLoggerForDjango", # Always on the top
"django.middleware...",
]
```
Expand All @@ -75,7 +75,7 @@ Then add a new section to `settings.py` for logging configuration, like this:

```python
USAGELOGGER = {
'url': 'http://localhost:4001/message',
'url': 'http://localhost:7701/message',
'rules': 'include debug'
}
```
Expand All @@ -86,12 +86,12 @@ USAGELOGGER = {

```python
from flask import Flask
from usagelogger.flask import HttpLoggerForFlask
from usagelogger.middleware.flask import HttpLoggerForFlask

app = Flask(__name__)

app.wsgi_app = HttpLoggerForFlask( # type: ignore
app=app.wsgi_app, url="http://localhost:4001/message", rules="include debug"
app=app.wsgi_app, url="http://localhost:7701/message", rules="include debug"
)

@app.route("/")
Expand All @@ -108,7 +108,7 @@ app.run(debug=True)
```python
from usagelogger import resurface

s = resurface.Session(url="http://localhost:4001/message", rules="include debug")
s = resurface.Session(url="http://localhost:7701/message", rules="include debug")
s.get(...)
```

Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ exclude = '''
'''

[tool.pytest.ini_options]
testpaths = [
"tests",
]
log_cli = true
log_cli_level = "CRITICAL"
log_cli_format = "%(message)s"
Expand All @@ -25,3 +28,8 @@ log_file = "test_debug.log"
log_file_level = "DEBUG"
log_file_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
log_file_date_format = "%Y-%m-%d %H:%M:%S"

[build-system]
requires = ["setuptools>=42.0", "wheel"]
build-backend = "setuptools.build_meta"

1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ pytest==6.2.2
Werkzeug==1.0.1
django==3.1.12
aiohttp==3.7.4
tox==3.24.3
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

19 changes: 15 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
from setuptools import find_packages, setup
from distutils import util

from setuptools import setup


def read_file(name):
with open(name) as fd:
return fd.read()


middleware = util.convert_path("usagelogger/middleware")
utils = util.convert_path("usagelogger/utils")

setup(
name="usagelogger",
version="2.2.6",
version="3.0.0",
description="Logging usage of Python-based services, with user privacy by design.",
long_description=read_file("DESCRIPTIONS.md"),
long_description_content_type="text/markdown",
Expand All @@ -27,9 +32,15 @@ def read_file(name):
"Programming Language :: Python :: 3.9",
],
keywords="logging resurface",
packages=find_packages(exclude=["tests"]),
package_dir={
"usagelogger": "usagelogger",
"usagelogger.middleware": middleware,
"usagelogger.utils": utils,
},
packages=["usagelogger", "usagelogger.middleware", "usagelogger.utils"],
# packages=find_packages(exclude=["tests"]),
python_requires=">=3.7, <4",
install_requires=read_file("requirements.txt").splitlines(),
install_requires=["requests>=2"],
include_package_data=True,
tests_require=["pytest"],
project_urls={
Expand Down
5 changes: 5 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os
import sys

sys.path.append("/usagelogger")
os.environ.setdefault("DEBUG", "True")
29 changes: 29 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[tox]
minversion = 3.8.0
envlist = py37, py38, py39, flake8, mypy
isolated_build = true

[gh-actions]
python =
3.7: py37
3.8: py38, mypy, flake8
3.9: py39

[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps =
-r{toxinidir}/requirements_dev.txt
commands =
pytest --basetemp={envtmpdir}

; [testenv:flake8]
; basepython = python3.8
; deps = flake8
; commands = flake8 usagelogger

; [testenv:mypy]
; basepython = python3.8
; deps =
; -r{toxinidir}/requirements_dev.txt
; commands = mypy usagelogger
7 changes: 7 additions & 0 deletions usagelogger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import middleware # noqa
from .base_logger import BaseLogger # noqa
from .http_logger import HttpLogger # noqa
from .http_message import HttpMessage # noqa
Expand All @@ -16,4 +17,10 @@
"BaseLogger",
"HttpLogger",
"HttpMessage",
"resurface",
"middleware",
# Depricating soon
"flask",
"django",
"aiohttp",
]
Loading

0 comments on commit ba89843

Please sign in to comment.