Skip to main content

my personal python library for convenient personalized functionality

Project description

cmon2lib

Personal Python library for convenient personalized functionality.

Logging

cmon2lib provides a unified logging system with cross-language compatibility (Python and Bash).

Dual-Output Logging

cmon2lib logs to both console (terminal) and file simultaneously:

Output Format When
Console Just the message (colored) Always
Console (WARNING/ERROR) WARN: message or ERR: message For WARNING/ERROR
File Full metadata: `YYYY-MM-DD HH:mm:ss LEVEL

Console Colors:

  • INFO: No color (clean output)
  • DEBUG/TRACE: Dim gray
  • SUCCESS: Green
  • WARNING: Yellow + WARN: prefix
  • ERROR: Red + ERR: prefix

File Format Example:

2026-04-12 18:14:00 | INFO    | ctaiga:get_authenticated_user:33 | simon | Authenticated user ID: 123

Console Output Example (same message):

Authenticated user ID: 123

For WARNING:

WARN: something went wrong

For ERROR:

ERR: connection failed

Python Usage

from cmon2lib.utils.cmon_logging import clog

# Basic logging
clog('info', 'message')
clog('debug', 'value: {}', 42)

# With exception
try:
    raise ValueError("test error")
except ValueError as e:
    clog('error', 'Operation failed', exception=e)
# Output: Operation failed: ValueError: test error

Bash Usage

source cmon_lib/cmon_logging.sh
init_clog "my_script"

clog_info "message"
clog_error "error message"
clog_warn "warning message"
clog_success "success message"

Log Levels

Level Python Bash Description
TRACE clog('trace', ...) N/A Detailed diagnostic
DEBUG clog('debug', ...) N/A Debug information
INFO clog('info', ...) clog_info General information
SUCCESS clog('success', ...) clog_success Success messages
WARNING clog('warning', ...) clog_warn Warnings
ERROR clog('error', ...) clog_error Errors
CRITICAL clog('critical', ...) N/A Critical errors

File Logging

Logs are automatically written to _clog/ directory next to the module:

  • Archive log: {timestamp}_{module}.log - all log messages
  • Summary log: {module}_csummary.log - INFO, SUCCESS, ERROR only

If WARN or ERROR is logged, the archive is renamed to *_WARN.log or *_ERR.log.

Log Cleanup

Archive logs older than 30 days are automatically deleted on initialization.

Protected files (never deleted automatically):

  • *_WARN.log - renamed warning archives
  • *_ERR.log - renamed error archives
  • *_csummary.log - summary logs

Features

  • Auto-init on first clog() call (Python)
  • Executing user tracking (via USER or USERNAME env vars)
  • Single-line exception formatting
  • Age-based cleanup (30 days for archives)
  • No external dependencies (uses loguru for Python)

Modules

ccaldav

Calendar integration for planning digests.

from cmon2lib.ccaldav import digest_schedule

schedule = digest_schedule(url, username, password)

ctaiga

Taiga project management integration.

from cmon2lib.ctaiga import get_authenticated_user, get_authenticated_user_projects

user = get_authenticated_user(username, password)
projects = get_authenticated_user_projects(username, password)

cowui

Open WebUI utilities for function injection.

from cmon2lib.cowui import inject_string_into_system_message

inject_string_into_system_message(body, "injected text", prefix="\n")

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

cmon2lib-0.0.9.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmon2lib-0.0.9-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file cmon2lib-0.0.9.tar.gz.

File metadata

  • Download URL: cmon2lib-0.0.9.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cmon2lib-0.0.9.tar.gz
Algorithm Hash digest
SHA256 e0b104053e371519b81bbe9b15709f6e75646d31848b23edb9bb13921305ccb0
MD5 cf7f5995adcbaf58a4c95902d2f38c55
BLAKE2b-256 c8d384d9815fa50cc0ae3d75add9d821e06e575be4fef74ed961a8b3e96ebecc

See more details on using hashes here.

File details

Details for the file cmon2lib-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: cmon2lib-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cmon2lib-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 9cbf91e6ea043806757c64dea06ec04a01826608c00a763f71afb9ab9e2bfc8e
MD5 9d3d089efdfe0033099649456c766c40
BLAKE2b-256 962a28538eb4ca9f37ea39b2ed47b09ac8d8bb4d9a53e25abd25af4f9a9337eb

See more details on using hashes here.

Supported by

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