Skip to content

Latest commit

 

History

History
72 lines (52 loc) · 1.77 KB

File metadata and controls

72 lines (52 loc) · 1.77 KB

Star Badge Open Source Love

LoggerLibrary

Description

A simple Python logging utility with console/file output and automatic log cleanup. This library provides an easy-to-use interface for setting up logging in your Python projects with minimal configuration.

Key Features:

  • Simple setup with one function call
  • Session tracking with auto-generated UUID to trace logs from the same execution
  • Dual output: log to console for debugging and file for persistent records
  • Auto cleanup: keep only recent logs (default: 3 days), no manual deletion needed

Languages or Frameworks Used

This project uses Python 3.x with only standard library modules (no external dependencies required).

How to run

Quick Start

  1. create demo.py

  2. Import the logger setup function:

from logger import setup_logger
  1. Choose your setup method:

Method 1: Customized Configuration

logger = setup_logger(
    name=__name__,
    enable_console=True,
    enable_file=True,
    level=logging.INFO,
    dir='./logs'
)
logger.debug('Debug message')
logger.info('Info message')

Method 2: Default Configuration

logger = setup_logger()
logger.debug('Debug message')
logger.info('Info message')
  1. Run your Python script:
python3 demo.py

Log Output Format

2025-11-16 00:41:00,951 | demo.py | INFO | 49e1e65d-2734-4807-81de-306ee628d788 | Your message

Demo

See the result of running the logger with both console and file output:

Author

Shyin Lim -> https://github.com/shyinlim