Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mlaradji/aiologger_async_httphandler
https://github.com/mlaradji/aiologger_async_httphandler
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mlaradji/aiologger_async_httphandler
- Owner: mlaradji
- Created: 2019-06-28T00:17:42.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-20T14:57:52.000Z (over 1 year ago)
- Last Synced: 2024-10-08T20:02:21.098Z (about 1 month ago)
- Language: Python
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
基于HTTP协议的异步logger的Handler。
作为
aiologger: https://github.com/B2W-BIT/aiologger
扩展的组件。使用aiohttp发送http请求。
**Example**
import asyncio
from aiologger import Logger
from aiologger.formatters.base import Formatter
async def main():
logger = Logger(name='my-logger')
formatter = Formatter("%(name)s - %(asctime)s - %(levelname)s")
handler = AsyncHTTPHandler(url="http://localhost:8081/index", method="POST", formatter=formatter)
logger.add_handler(handler)
tasks = [
logger.debug("debug at stdout"),
logger.info("info at stdout"),
logger.warning("warning at stderr"),
logger.error("error at stderr"),
logger.critical("critical at stderr")
]
await asyncio.wait(tasks)
await logger.shutdown()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()