Skip to main content

Log data in google chat

Project description

Google Chat Handler

Python logging handler to push the logs to google chat root using the webhook url. Just create a room or use existing room and create a webhook url of a bot and pass the URL to this GoogleChatHandler library.

Installation Instruction!

  • Activate your Virtual Environment.
  • pip install google_chat_handler


  1. Google chat handler library give us the GoogleChatHandler class that we have to use and attach the handler to any logger of class logging. It is also compatible with flask and django logger.


  1. Import Google Chat Handler

    • from google_chat_handler import GoogleChatHandler
  2. Initialize the chat handler

    • handler = GoogleChatHandler('')
  3. Set the level of the handler

    • let say if we want to push only error logs to google chat as a alert
    • handler.setLevel(logging.ERROR)
  4. Add the handler to the existing logger

    • logger.addHandler(handler)
  5. Now use the google chat handler

    • logger.error("This message will appear in google chat")


import logging
from google_chat_handler import GoogleChatHandler
# logger of your project

# Get default logger
logger = logging.getLogger()
# set default level of the logger

# Create google_chat_handler for google chat google_chat_handler
handler = GoogleChatHandler(webhook_url="")
# Set level of the Google chat google_chat_handler for which loglevel we have to send logs to google
# Add the google_chat_handler to the logger
logger.addHandler(handler)"normal logger info")
logger.debug("normal logger debug")

# Only below log will be pushed to google chat
logger.error("google chat logger error")

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_chat_handler-1.0.1.tar.gz (3.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page