Skip to main content

Handy logging tool to send logs to MSTeams with or without filters.

Project description

pigeons

Pigeons is an easy and practical alert tool which enables sending logs to MSTeams. It also supports dynamic filtering of log records with an option to use regex to capture records of any logger.

Installation

Installing through pip

pip install pigeons

Build from source

git clone https://github.com/obss/pigeons
cd pigeons
python setup.py install

Usage

Pigeons is easy to use with just two line of codes.

import sys

from pigeons import init_logger, pigeon_excepthook

sys.excepthook = pigeon_excepthook
logger = init_logger(
    ...
)

With Start Flags

Pigeons will look for specified flags in the beginning of the log for the specified log level. If the log message starts with the flag, then it will be sent to specified endpoint.

import logging

from pigeons import init_logger

endpoint = "https://custom_domain.com/api/..."
my_flag = "!my_flag "
logger = init_logger(
        endpoint=endpoint,
        level=logging.INFO, # Default
        log_to_teams=True,
        tf_capture_flags=[my_flag],
        tf_regex=False
)

With Regex

Pigeons will look for specified regex in the log for the specified log level. If the log message matches the regex, then it will be sent to specified endpoint.

import logging

from pigeons import init_logger

endpoint = "https://custom_domain.com/api/..."
my_regex = "^[a-zA-Z0-9]+$"
logger = init_logger(
        endpoint=endpoint,
        level=logging.INFO, # Default
        log_to_teams=True,
        tf_capture_flags=[my_regex],
        tf_regex=True
)

Uncaught Exceptions

Pigeons has a custom excepthook for handling uncaught exceptions. To handle uncaught exceptions just override sys.excepthook as follows

importy sys
from pigeons import pigeon_excepthook

sys.excepthook = pigeon_excepthook

Examples

# Lower levels will be ignored.
logger.debug("This log will be ignored.")

# At level=level (logging.INFO)
logger.info("This log is ignored".)
logger.info(my_flag + "This log is captured and sent to Teams.")

# Higher levels will always be captured regardless presence of flag.    
logger.warning("This is sent.")
logger.error("This is also sent.")
logger.critical("Another captured message.")
logger.fatal("And another one.")

Contributing

PRs are always welcomed.

Installation

git clone https://github.com/obss/pigeons.git
cd pigeons
python setup.py develop
pip install -r requirements-dev.txt

Tests

To tests simply run.

pytest tests/

Pigeons uses black to assure code style standard.

black . --config pyproject.toml

License

Licensed under the MIT License.

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

pigeons-0.0.4.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

pigeons-0.0.4-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pigeons-0.0.4.tar.gz.

File metadata

  • Download URL: pigeons-0.0.4.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for pigeons-0.0.4.tar.gz
Algorithm Hash digest
SHA256 1502e4c982984110030287d57bebfa09d8bdaa9e6d5819f589cda0d07872f3b0
MD5 3037083baebb0b1e8f059d82ea671b9d
BLAKE2b-256 3f5b14823d1a88f9071e10e874726f78012c369d04bc50ea72a8d32bbb368657

See more details on using hashes here.

File details

Details for the file pigeons-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pigeons-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for pigeons-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bae581bc1ccc1f6acf169d698d0b1080bad8404a27656ba7a34917d6545ca839
MD5 fad7b79b06b87954267c27a834d6d069
BLAKE2b-256 8689d183b4556b51a1e8808d38a7272a28dd5e5c2a9a6ac3d04e54d118ca51ef

See more details on using hashes here.

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