diff --git a/src/mololog.egg-info/PKG-INFO b/src/mololog.egg-info/PKG-INFO index b2da6ef..6870e79 100644 --- a/src/mololog.egg-info/PKG-INFO +++ b/src/mololog.egg-info/PKG-INFO @@ -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") +``` diff --git a/src/mololog.egg-info/SOURCES.txt b/src/mololog.egg-info/SOURCES.txt index 0fbb675..89856d5 100644 --- a/src/mololog.egg-info/SOURCES.txt +++ b/src/mololog.egg-info/SOURCES.txt @@ -1,3 +1,4 @@ +README.md pyproject.toml setup.cfg src/mololog/__init__.py diff --git a/src/mololog/client.py b/src/mololog/client.py index 53da07c..84611c9 100644 --- a/src/mololog/client.py +++ b/src/mololog/client.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 diff --git a/src/mololog/server.py b/src/mololog/server.py index 7205aa3..93dd71c 100644 --- a/src/mololog/server.py +++ b/src/mololog/server.py @@ -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) diff --git a/test.py b/test.py index 5ca3b50..093c38a 100644 --- a/test.py +++ b/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!") - -