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.0.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.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: smlog-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 e03b584afac3e442f91818ddc67e28f134f4d10f92c9d0ea1dfb492a8a7a3a48
MD5 16f33d568596c21a329aee2241b2a072
BLAKE2b-256 ca83efd80a11e69b96eedbcc7a2376649c20b89cb2c3f65aba7fe9d5ca4b8adb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smlog-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b3ef9d885399670cb1aa644244be7c8c504d3f7f2d9005221ec3bf533578634
MD5 9cd8f0cca7509172afc550db7a445c6d
BLAKE2b-256 d6364ce4cd9afebebd1e603e898ca75afef4c362eab6fd6ca7724b400926000a

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