Python logging handler for Microsoft Teams webhook integration with both simple and dictionary configurations.
This package requires Python 3.8 or newer.
Installation
pip install teams-logger
Examples
Simple configuration
import logging
from teams_logger import TeamsHandler
th = TeamsHandler(url='YOUR_WEB_HOOK_URL', level=logging.INFO)
logging.basicConfig(handlers=[th])
logging.warning('warn message')
Simple configuration and non blocking handler
import logging
from teams_logger import TeamsQueueHandler
th = TeamsQueueHandler(url='YOUR_WEB_HOOK_URL', level=logging.INFO)
logging.basicConfig(handlers=[th])
logging.info("info message")
Simple configuration and Card Formatter
import logging
from teams_logger import TeamsHandler, Office365CardFormatter
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
th = TeamsHandler(url='YOUR_WEB_HOOK_URL', level=logging.INFO)
th.setLevel(logging.DEBUG)
logger.addHandler(th)
cf = Office365CardFormatter(facts=["name", "levelname", "lineno"])
th.setFormatter(cf)
logger.debug('debug message')
logger.info('info message')
logger.warning('warning message')
logger.error('error message')
logger.critical('critical message')
try:
2/0
except ZeroDivisionError as e:
logger.error('Oops !', exc_info=True)
Dictionary configuration and Card Formatter
import logging
import logging.config
from teams_logger import TeamsHandler, Office365CardFormatter
url = 'YOUR_WEB_HOOK_URL'
logging_dict = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'teamscard': {
'()': Office365CardFormatter,
'facts': ["name", "levelname", "lineno"],
},
},
'handlers': {
'msteams': {
'level': logging.INFO,
'class': 'teams_logger.TeamsHandler',
'url': url,
'formatter': 'teamscard',
},
},
'loggers': {
__name__: {
'handlers': ['msteams'],
'level': logging.DEBUG,
}
},
}
logging.config.dictConfig(logging_dict)
logger = logging.getLogger(__name__)
logger.info('Info message')
Release files for teams-logger 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| teams_logger-0.5.1.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| teams_logger-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / teams_logger-0.5.1.tar.gz
| Download URL | teams_logger-0.5.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb933ca6ea12a5d393571836c060e61d29598f2126b7d8b777769f7be415800b
|
|
BLAKE2b-256 checksum How to use checksums |
e79a769366d48d2d01e109d6dd3e40b278b21fb304d7bc5ca36c0a8d259c18bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / teams_logger-0.5.1-py3-none-any.whl
| Download URL | teams_logger-0.5.1-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a62398469f3fc0ac74185527d1076323aaba6c9759b89ac62c26c59ff95b9c8e
|
|
BLAKE2b-256 checksum How to use checksums |
889dd20a3bf2ae933e225b48b6589154178ab01af91471067db437ee95b48604
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|