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

Uploaded Python 3

File details

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

File metadata

  • Download URL: smlog-1.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f2a7ef793fb53e4068a4c088e03a58f7137bd669e3090f7a3099810b3ad4ecae
MD5 3a66fbe7890b9850998cde4d3eec286b
BLAKE2b-256 9ba6c0305a802f53bc6231f387551d23864e332098946fb67a0b90c8613d2368

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smlog-1.0.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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46255c447231604973d1eeba29f83ec99b6e0eeca2def8bfe92ab472e0a2c7cc
MD5 6bfde2cfa767f11cf0b103fd13c70383
BLAKE2b-256 469800baf351466b229079fa3b66c9a0140b4300b285d7563081da566d5ffa53

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