Automated update of package.
This commit is contained in:
parent
178c72404d
commit
c93d588ff1
@ -10,3 +10,22 @@ Description-Content-Type: text/markdown
|
||||
Requires-Dist: requests==2.32.3
|
||||
Requires-Dist: aiohttp
|
||||
Requires-Dist: app@ git+https://retoor.molodetz.nl/retoor/app.git
|
||||
|
||||
# Mololog
|
||||
|
||||
Mololog is a logging framework for python applications.
|
||||
|
||||
It contains three applications:
|
||||
- mololog.serve
|
||||
- mololog.test
|
||||
- mololog.bench
|
||||
|
||||
## Running mololog server
|
||||
```
|
||||
mololog.serve --host=127.0.0.1 --port=3016 --db=mololog.db
|
||||
```
|
||||
## Implementation of logger in application
|
||||
```
|
||||
from mololog.client import patch
|
||||
patch("https://your-logging-server.nl")
|
||||
```
|
||||
|
@ -1,3 +1,4 @@
|
||||
README.md
|
||||
pyproject.toml
|
||||
setup.cfg
|
||||
src/mololog/__init__.py
|
||||
|
@ -63,7 +63,7 @@ class HTTPLogger(logging.Handler):
|
||||
|
||||
def get_logger_names():
|
||||
loggers = logging.Logger.manager.loggerDict
|
||||
for name, _ in loggers.items():
|
||||
for name, _ in loggers.items():
|
||||
yield name
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
import json
|
||||
import uuid
|
||||
import asyncio
|
||||
|
||||
from aiohttp import web
|
||||
from app.app import Application as BaseApplication
|
||||
|
||||
@ -8,13 +9,12 @@ from app.app import Application as BaseApplication
|
||||
class Application(BaseApplication):
|
||||
|
||||
def __init__(self, test=0, *args, **kwargs):
|
||||
|
||||
|
||||
self.test = test
|
||||
self.total_received = 0
|
||||
|
||||
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
self.middlewares.append(self.test_middleware)
|
||||
|
||||
self.router.add_post("/emit", self.handle_emit)
|
||||
@ -22,17 +22,15 @@ class Application(BaseApplication):
|
||||
async def exit_app(self):
|
||||
await asyncio.sleep(1)
|
||||
exit(0)
|
||||
|
||||
@web.middleware
|
||||
async def test_middleware(self,request,handler):
|
||||
result = await handler(request)
|
||||
|
||||
@web.middleware
|
||||
async def test_middleware(self, request, handler):
|
||||
result = await handler(request)
|
||||
|
||||
if self.total_received == self.test:
|
||||
await asyncio.create_task(self.exit_app())
|
||||
|
||||
|
||||
return result
|
||||
|
||||
|
||||
async def handle_emit(self, request):
|
||||
data = await request.json()
|
||||
@ -54,11 +52,11 @@ def parse_args():
|
||||
parser.add_argument("--host", type=str, required=True)
|
||||
parser.add_argument("--port", type=int, required=True)
|
||||
parser.add_argument("--db", type=str, required=True)
|
||||
parser.add_argument("--test", type=int, required=False,default=0)
|
||||
parser.add_argument("--test", type=int, required=False, default=0)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def serve():
|
||||
args = parse_args()
|
||||
app = Application(db_path=f"sqlite:///{args.db}",test=args.test)
|
||||
app = Application(db_path=f"sqlite:///{args.db}", test=args.test)
|
||||
app.run(host=args.host, port=args.port)
|
||||
|
16
test.py
16
test.py
@ -1,21 +1,25 @@
|
||||
import subprocess
|
||||
import shlex
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
processes = [
|
||||
subprocess.Popen(shlex.split("./.venv/bin/mololog.serve --host=127.0.0.1 --port=3999 --db=':memory:' --test=3")),
|
||||
subprocess.Popen(shlex.split("./.venv/bin/mololog.test --url=http://localhost:3999"))
|
||||
subprocess.Popen(
|
||||
shlex.split(
|
||||
"./.venv/bin/mololog.serve --host=127.0.0.1 --port=3999 --db=':memory:' --test=3"
|
||||
)
|
||||
),
|
||||
subprocess.Popen(
|
||||
shlex.split("./.venv/bin/mololog.test --url=http://localhost:3999")
|
||||
),
|
||||
]
|
||||
|
||||
for process in processes:
|
||||
while True:
|
||||
process.poll()
|
||||
if not process.returncode is None:
|
||||
if process.returncode is not None:
|
||||
if process.returncode != 0:
|
||||
exit(process.returncode)
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
print("Test sucess!")
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user