Webex Logging Handler
This is a simple Python logging handler that emits messages to Webex incoming Webhooks.
Installing
To install run:
python -m pip install git+https://github.com/xorrkaz/webex-log-handler.git
Usage
First, obtain an incoming webhook URL from https://apphub.webex.com/messaging/applications/incoming-webhooks-cisco-systems-38054.
Here is a trivial usage. But you'll likely want to use a logger.conf or the like.
import logging
from webex_handler import WebexHandler
logger = logging.getLogger(__name__)
# The notice level is more severe than INFO but not as severe as WARNING.
logger.setLevel(WebexHandler.NOTICE)
logging.addLevelName(WebexHandler.NOTICE, "NOTICE")
wx = WebexHandler("https://webexapis.com/v1/webhooks/incoming/...")
wx.setLevel(WebexHandler.NOTICE)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
wx.setFormatter(formatter)
logger.addHandler(wx)
logger.log(WebexHandler.NOTICE, "Logging from Python!")
If you are using asyncio, there is an async version of the handler as well. It requires the aiolog and aiohttp packages, though. To use it:
pip install aiolog aiohttp
import asyncio
import aiolog
import logging
from webex_handler import AsyncWebexHandler
logger = logging.getLogger(__name__)
# The notice level is more severe than INFO but not as severe as WARNING.
logger.setLevel(AsyncWebexHandler.NOTICE)
logging.addLevelName(AsyncWebexHandler.NOTICE, "NOTICE")
wx = AsyncWebexHandler("https://webexapis.com/v1/webhooks/incoming/...")
wx.setLevel(AsyncWebexHandler.NOTICE)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
wx.setFormatter(formatter)
logger.addHandler(wx)
async def do_work():
logger.log(AsyncWebexHandler.NOTICE, "Logging from Python!")
aiolog.start()
loop = asyncio.get_event_loop()
loop.run_until_complete(do_work())
loop.run_until_complete(aiolog.stop())
Et voilà!
Other Info
The WebexHandler uses markdown-formatted messages by default, but you can pass use_markdown=False to the WebexHandler constructor to use plain text.
Also, be cognizant than a high level (like INFO or DEBUG) can make things very chatty in Webex. Consider a lower level to minimize noise.
Metadata
Release files for webex-handler 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| webex_handler-2.0.0.tar.gz | 3.7 kB | Without provenance | Details for webex_handler-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| webex_handler-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for webex_handler-2.0.0-py3-none-any.whl |
Total release size: 8.8 kB
Release files / webex_handler-2.0.0.tar.gz
| Download URL | webex_handler-2.0.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c422d4fcdc18c73cd2ac8202751e661914c8fc083c33be8729cca26a45eaa9f7
|
|
BLAKE2b-256 checksum How to use checksums |
0bcaa868d07dbbaead4db8bda28a6b9fd653f1638aab05dab044d495e05608c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Release files / webex_handler-2.0.0-py3-none-any.whl
| Download URL | webex_handler-2.0.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa22317f0f549b70be23b912ba13446293404214e4ade68c01544a3f332310c9
|
|
BLAKE2b-256 checksum How to use checksums |
0cc0d923fe0cae69f24b8f0aa4b6826c97ea641d088419a2868a71a4e80a4892
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Security for webex-handler 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.