Metadata-Version: 2.4
Name: smlog
Version: 1.2.0
Summary: A simple Python logger with colors and file output
Author: Nikita Oleynik
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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

```bash
pip install smlog
```

#### Create a logger

``` bash
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

``` bash
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

``` bash
try:
    1 / 0
except Exception as e:
    logger.error("This is an error message", exc=e)
```

# Log messages of different levels

``` bash
- 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

``` bash
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
```
