Skip to main content

A simple Python logger with colors and file output

Project description

smlog

A simple Python logger with colored console output, optional file logging, and daily log rotation.

Features

  • Colored console output for different log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • Optional logging to files with automatic directory creation
  • Daily log rotation
  • Minimal setup and easy-to-use interface
  • Customizable minimum log level

Installation

pip install smlog

Create a logger

from smlog import Logger

logger = Logger(
    name="user",
    min_level="INFO",
    use_colors=True,
    log_to_file=True,
    log_dir="logs",
    rotate_daily=True
)

Example

from smlog import Logger

logger = (
    name="user",
    min_level="INFO",
    use_colors=True,
    log_to_file=True,
    log_dir="logs",
    rotate_daily=True
)

logger.log("info", "Server has been started")
or
logger.info("Server has been started")

Log messages of different levels

- logger.debug("This is a debug message") # Will not be shown if min_level is INFO

- logger.info("This is an info message")

- logger.warning("This is a warning")

- logger.error("This is an error")

Logging to File

Logs are saved to the specified log_dir

File names are either log.log or daily rotated (YYYY-MM-DD.log)

Each log entry is separated for clarity:
[2026-01-25 23:45:12] [WARNING] [user] message

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

smlog-0.1.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

smlog-0.1.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file smlog-0.1.1.tar.gz.

File metadata

  • Download URL: smlog-0.1.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for smlog-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aa13a20faaef6d23b31569cf584c45a879e07f8a4074a9e242c294301045e306
MD5 c9c4eb31f9b45d0f47f2521429cc80a9
BLAKE2b-256 131c7ad21441d37fa3739ae1d7e3f0b883ce41bbfadf235f2bed18034849edad

See more details on using hashes here.

File details

Details for the file smlog-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: smlog-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for smlog-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8350954c01d46fca832b084c47650da7927eba412341cf8814f71454b4782800
MD5 e905b24e267a6816ec1c8c1210e6c7e6
BLAKE2b-256 051451ce4aec57e4ed347aff76b86417f41557ac755fa28272c6e4246b6c9895

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