Skip to main content

Development utilities with structured logging

Project description

Dev Utils

A collection of development utilities, starting with structured logging.

Installation

pip install dev-utils-jokerssd

Logging Utils

A powerful wrapper around structlog and Python's standard logging module to provide structured JSON logging with rotation, async writing, and easy configuration.

Usage

from dev_utils import LoggingUtils

# Basic Setup
logging_utils = LoggingUtils(
    log_file="app.log",
    log_level="INFO",
    print_output=True,
    json_formatter=True,
    binding_dict={"app_name": "my_app"}
)

logger = logging_utils.get_logger()

# Log something
logger.info("Application started", version="1.0.0")

# Exception logging
try:
    1 / 0
except ZeroDivisionError:
    logger.exception("Something went wrong")

Features

  • Structured JSON Logs: By default, logs are formatted as JSON for easy parsing by log management tools.
  • Async Logging: Uses a background thread for file writing to avoid blocking the main execution path.
  • Log Rotation: Automatically rotates log files daily (default).
  • Context Binding: Bind global context variables (like request_id or user_id) to all logs.
  • Standard API: Compatible with standard python logging (mostly) and structlog.

Lark Wrapper

A wrapper for interaction with Lark/Feishu Custom bots, providing strong typing and error handling.

Usage

from dev_utils.lark_wrapper import MsgBot, BotType, MsgType, BotStatus

# Initialize the bot
bot = MsgBot(
    chat_id="your-chat-id",
    url="https://open.larksuite.com/open-apis",
    api_name="bot/v2/hook/",
    bot_type=BotType.LARK
)

# Send a text message
response = bot.send_cust_bot_msg(
    message="Hello, World!",
    msg_type=MsgType.TEXT,
    title="Notification"
)

# Check response
if response.status == BotStatus.OK:
    print("Success:", response.msg)
else:
    print("Failed:", response.errors)

Features

  • Strong Typing: Uses BotStatus, BotType, and BotResponse for predictable API interactions.
  • Multi-Platform Support: Extensible design (currently supports Lark).
  • Async Support: async_send_msg available for non-blocking operations.
  • Rich Content: Supports Post/Rich Text messages via MsgType.POST.

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

dev_utils_jokerssd-0.5.1.tar.gz (74.8 kB view details)

Uploaded Source

Built Distribution

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

dev_utils_jokerssd-0.5.1-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file dev_utils_jokerssd-0.5.1.tar.gz.

File metadata

  • Download URL: dev_utils_jokerssd-0.5.1.tar.gz
  • Upload date:
  • Size: 74.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for dev_utils_jokerssd-0.5.1.tar.gz
Algorithm Hash digest
SHA256 b5419839d63446a4e6a90116e030978260f10d37d591b31091a671205068a475
MD5 a48ed2ecce557de03280574249d976ec
BLAKE2b-256 9244eb267549346b1c5ab0c4678030c9a603edfc0eb08be118ce1695cc23485e

See more details on using hashes here.

File details

Details for the file dev_utils_jokerssd-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dev_utils_jokerssd-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6a1a66f86caaec12e8ae7a54576f6f4ce08a4b7f260746b39b1dfe5fab10de06
MD5 9f3e3f359c57d8d3184541cba2929a50
BLAKE2b-256 1ca88aae2078ec333e2ad417ed76b0dae309de93b5199432a976a6863e044943

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