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)
  • Optional logging to files with automatic directory creation
  • Daily log rotation
  • Minimal setup and easy-to-use interface
  • Customizable minimum log level
  • Unlimited amount of parameters for logging
  • Optional logs writing in console

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,
    console=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,
    console=True
)

logger.log("info", "Server has been started", user="user") # user is a parameter, u can add as many as u need to

or

logger.info("Server has been started", role="admin") # role is a parameter, u can add as many as u need to
Exception
try:
    1 / 0
except Exception as e:
    logger.error("This is an error message", exc=e)

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.2.0.tar.gz (3.8 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.2.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for smlog-1.2.0.tar.gz
Algorithm Hash digest
SHA256 0db91ad911b293de11530d5186747da24a89387503da6b2fa822954bd0b6ede1
MD5 c8b4937e3e0952522f29bf730c2425f1
BLAKE2b-256 19f803a3b564763960922eeaf04f45b31f6b51c0eef0d12863cb6cfa359cc878

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smlog-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18cbd7c15e7e39e2ba925ce97a9293787f4f89293e15bd3c8595a6a6f8f517e8
MD5 64ddc1c3c158c2da748e98334069b892
BLAKE2b-256 4c49623f9e81cd1da625a53b01c15e6167bb5930fc239d55c3da11fb424ad21b

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