Skip to main content

teams-logger

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')

Metadata

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)

Source distribution for teams-logger 0.5.1
File Size Uploaded Provenance Actions
teams_logger-0.5.1.tar.gz 4.1 kB Without provenance Details for teams_logger-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for teams-logger 0.5.1
File Interpreter ABI Platform Actions
teams_logger-0.5.1-py3-none-any.whl Python 3 none any Details for teams_logger-0.5.1-py3-none-any.whl

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

Security for teams-logger 0.5.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page