New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

setlogging

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

setlogging

A flexible logging utility with JSON support and timezone awareness

pipPyPI
Version
0.3.2
Maintainers
1

Setlogging

Python PyPI version License: MIT

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

Author

  • Name: Jie Yan
  • Contact: kiki3890528@gmail.com

Features

  • JSON and plain text log formats
  • Log file rotation with size limits
  • Console and logfile 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 with log file
logger = get_logger(console_output=False, logfile="./logs/app.log")
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
├── README.md
└── LICENSE

Configuration Options

OptionTypeDefaultDescription
log_levelintDEBUGLogging level
log_filestrFalseLog file path
max_size_mbint25Max file size in MB before rotation
backup_countint7Number of backup files
console_outputboolTrueEnable console logging
log_formatstrNoneCustom log format string
date_formatstrNoneCustom date format string
json_formatboolFalseEnable JSON formatting
indentintNoneJSON indentation level

Keywords

json

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts