Skip to main content

A timezone-configurable logging package based on loguru with Shanghai timezone as default

Project description

LogFtz - Timezone-Configurable Logging Package

A Python logging package based on loguru with configurable timezone support. Defaults to Shanghai timezone (Asia/Shanghai) but allows users to set any timezone.

Features

  • 🕐 Configurable timezone support (defaults to Asia/Shanghai)
  • 📊 Configurable minimum log level (defaults to INFO)
  • 📝 Clean log format: MM-DD HH:mm:ss|LEVEL|MESSAGE
  • 📁 Automatic daily log file rotation
  • 🗂️ Automatic retention of last 3 days of log files
  • 🚀 Built on high-performance loguru library

Installation

pip install logftz

Usage

Basic Usage

from logftz import logger

logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.debug("This is a debug message")

Set Log Level

from logftz import logger

# Set minimum log level to DEBUG (show all logs)
logger.set_level('DEBUG')
logger.debug("This debug message will now be shown")

# Set minimum log level to WARNING (hide INFO and DEBUG)
logger.set_level('WARNING')

Set Timezone

from logftz import logger

logger.set_timezone('UTC')
logger.set_timezone('America/New_York')
logger.set_timezone('Asia/Shanghai')

Log Output Example

12-25 14:30:15|INFO|This is an info message
12-25 14:30:16|WARNING|This is a warning message
12-25 14:30:17|ERROR|This is an error message

Configuration

  • Default Timezone: Asia/Shanghai
  • Default Log Level: INFO
  • File Path: logs/YYYY-MM-DD.log
  • Rotation: Daily rotation
  • Retention: Keep last 3 days of log files
  • Format: MM-DD HH:mm:ss|LEVEL|MESSAGE

API Reference

Methods

  • logger.set_level(level: str): Set minimum log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • logger.set_timezone(timezone: str): Set timezone for logging

License

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

logftz-4.0.0.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file logftz-4.0.0.tar.gz.

File metadata

  • Download URL: logftz-4.0.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for logftz-4.0.0.tar.gz
Algorithm Hash digest
SHA256 f369c3b4c0ce47291ce17b3169c48bc722cc9a206709fd068cd288b0a313ff73
MD5 d4279d3d9f9cec022860d95ec867b97d
BLAKE2b-256 57c096d7ae67a4762da2782b40dcbbdadb7653cf8165497fdfa72b515a906092

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