Skip to main content

A flexible logging utility with JSON support and timezone awareness

Project description

Setlogging

Python PyPI version License: MIT

A flexible Python logging utility with JSON support and timezone awareness.

Author

Features

  • JSON and plain text log formats
  • Log file rotation with size limits
  • Console output options
  • Timezone-aware logging
  • Customizable formatting
  • Type-safe configuration

Installation

pip install setlogging

Usage

from setlogging import get_logger

# Basic logging
logger = get_logger()
logger.info("Basic log message")

# JSON logging with indentation
logger = get_logger(json_format=True, indent=2)
logger.info("Structured logging")

# Custom file and rotation
logger = get_logger(
    log_file="/tmp/app.log",
    max_size_mb=10,  # 10MB
    backup_count=5
)

# Disable console output
logger = get_logger(console_output=False)
logger.info("This will not be printed to the console")

Project Structure

setlogging/
├── src/
│   └── setlogging/
│       ├── __init__.py
│       └── logger.py
├── tests/
│   ├── __init__.py
│   └── test_logger.py
├── pyproject.toml
├── README.md
└── LICENSE

Configuration Options

Option Type Default Description
log_level int DEBUG Logging level
log_file str app.log or app_json.log Log file path
max_size_mb int 25 Max file size in MB before rotation
backup_count int 7 Number of backup files
console_output bool True Enable console logging
log_format str None Custom log format string
date_format str None Custom date format string
json_format bool False Enable JSON formatting
indent int None JSON indentation level

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

setlogging-0.3.1.tar.gz (94.0 kB view details)

Uploaded Source

Built Distribution

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

setlogging-0.3.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file setlogging-0.3.1.tar.gz.

File metadata

  • Download URL: setlogging-0.3.1.tar.gz
  • Upload date:
  • Size: 94.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for setlogging-0.3.1.tar.gz
Algorithm Hash digest
SHA256 9f1d3412c62e7e867b81b0441503bd04eab50007c115e6bd8803b763e86f3408
MD5 239b6633aef5831a6b04f87b825588a0
BLAKE2b-256 e481f165d59c79e7563ff584a9ef2cf2717fcc770e8b244bd51eea2f87ca8afa

See more details on using hashes here.

File details

Details for the file setlogging-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: setlogging-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for setlogging-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac61b0f0aa97c40ddecdae996da01464d64bae88922862ab97bba450d725466d
MD5 fdb3cd7cf9cacbfcc7c56f41b1b6f2a5
BLAKE2b-256 1b45cd8b44783e1f04fc6393f6a3361161149f2c9b9dd7a371abfb930f47bf7e

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