Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

teams-logger

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

teams-logger

Microsoft Teams logging handler for Python

  • 0.4.1
  • PyPI
  • Socket score

Maintainers
1

teams-logger

Python logging handler for Microsoft Teams webhook integration with both simple and dictionary configurations.

Installation

.. code-block:: bash

pip install teams-logger

Examples

Simple configuration '''''''''''''''''''' .. code-block:: python

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 ''''''''''''''''''''''''''''''''''''''''''''' .. code-block:: python

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 ''''''''''''''''''''''''''''''''''''''' .. code-block:: python

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 ''''''''''''''''''''''''''''''''''''''''''' .. code-block:: python

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc