Skip to main content

Gytrash

A logging setup module for Python. When setting up logging functionality for new projects I noticed I was always following the same pattern.

Decided to put these practices into a module. The module sets up a logger using coloredlogs. You can attach the botocore logs, if you are a regular user of boto3. And the logger can easily ship logging messages to slack.

Installation

pip install gytrash

Examples

Simple logging setup

import gytrash
import logging
log = logging.getLogger("slack_example")

gytrash.setup_logging(log, log_level=10)

log.info("Test info message")
log.debug("Test debug message")

Setup logger for use with Slack

To use gytrash to ship logging messages to slack, first setup a slack app using this walkthrough

Once you have generated the bot token, save it as an environment variable.

Set Slack Environment Variables

export SLACK_BOT_TOKEN="<BOT TOKEN>"

Finally setup gytrash using the extended parameters.

Import Gytrash and setup logger to use Slack

import gytrash
import logging
log = logging.getLogger("slack_example")

gytrash.setup_logging(log, log_level=10, log_from_botocore=False, log_to_slack=True, slack_log_channel="<LOG NAME>", slack_log_level=20)

log.info("Test info message")
log.debug("Test debug message")

log.info("Test info message", extra={"notify_slack": True})  # send this log message to slack

Release Process

Create a release branch from main:

main >> release/v0.0.11 (No change in version number)

Create a feature branch from main:

main >> feature/new_feature_to_add (No change in version number)

Work on feature and then PR feature to release branch:

release/v0.0.11 << feature/new_feature_to_add (Version bumped to next patch 0.0.12a{PR_NUMBER}.post0 on PR open.)

When release is ready, PR back to main: main << release/v0.0.11 (Version is bumped to next version number v0.0.12)

If you have more than one feature PR going into a release, then the feature PR version must be managed semi-manually. Before the PR is opened, you must pull the commit that was automatically created during the release test and pypi package upload from the destination release branch.

After pulling the commit, update these two files back to the version number from main when you created this feature branch:

.bumpversion.cfg
gytrash/__about__.py

Metadata

Release files for gytrash 0.0.22

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gytrash 0.0.22
File Size Uploaded
gytrash-0.0.22.tar.gz 12.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gytrash 0.0.22
File Interpreter ABI Platform
gytrash-0.0.22-py3-none-any.whl Python 3 none any Details

Total release size: 26.8 kB

Release files / gytrash-0.0.22.tar.gz

Download URL gytrash-0.0.22.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
51d131567610a34fe564497d9b89451eb88756e26c386baaad45415b11c93275
BLAKE2b-256 checksum
How to use checksums
99704924d54bb19dde8a27c198a4402f51cfd870e247c2ed1f3a9100d5e46638
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.2 Darwin/23.0.0

Release files / gytrash-0.0.22-py3-none-any.whl

Download URL gytrash-0.0.22-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c586493fd120002b79f864a5ffd96571a4a7c1c6eb0994451c02ce6f41ffba4
BLAKE2b-256 checksum
How to use checksums
8114ffbe62b1fe69fe6782df47fdf5c05ddd24e5a76eeb9b72b95b6b10fdd39c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.2 Darwin/23.0.0

Release history Release notifications | RSS feed

This release

0.0.22 This release

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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