Easy and consistent logging to file with console output
Project description
Effortless logging to both file and console with automatic timestamped filenames.
Features
Simple API for configurable logging to file and console
Automatic timestamped log files (myapp_20240326143022.log)
Consistent log formatting across your application
Full Python 3.7+ support
Type hints for better IDE support
Proper error handling and validation
Installation
pip install smoothlogging
Quick Start
Using the convenience function:
from smoothlogging import get_logger
logger = get_logger("/var/log/myapp", "myapp")
logger.info("Application started")
logger.warning("Something unexpected happened")
logger.error("An error occurred")
Using the SmoothLogging class:
from smoothlogging import SmoothLogging
import logging
smooth = SmoothLogging()
logger = smooth.get_logger("/var/log/myapp", "myapp", level=logging.DEBUG)
# Log to file and console (default)
logger.info("Message with file and console output")
# Create another logger without console output
file_only = smooth.get_logger("/var/log/myapp", "file-only", console=False)
API Reference
get_logger(log_dir, name, level=logging.DEBUG, console=True)
Convenience function to create and configure a logger.
log_dir: Directory for log files (created if doesn’t exist)
name: Logger and log file prefix name
level: Logging level (default: DEBUG)
console: Enable console output (default: True)
Returns: Configured logger instance
SmoothLogging.get_logger(…)
Class method with same parameters as convenience function.
SmoothLogging.get_existing_logger(name)
Retrieve a previously created logger by name. - Returns: Logger instance or None if not found
# CI/CD Fixed
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smoothlogging-1.0.0.tar.gz.
File metadata
- Download URL: smoothlogging-1.0.0.tar.gz
- Upload date:
- Size: 58.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f88525f6d0a80edb89d6b5d04cf934a43d5a258d3a1ac7f847052612e502b2b
|
|
| MD5 |
66f80b7261e37b3ce8d6becad94f544f
|
|
| BLAKE2b-256 |
c431d6bf5741616a309f0fd8654532bb815a8958d4b0d57dcd1a8b59d601ec55
|
File details
Details for the file smoothlogging-1.0.0-py2.py3-none-any.whl.
File metadata
- Download URL: smoothlogging-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee892e5fadc739d636946a7a0438201f70e232213cc7962eeed8de6712655611
|
|
| MD5 |
88aa6d2269623d1f8b8a7a8dcd8695fa
|
|
| BLAKE2b-256 |
7a7105657ef6c1c56e735a1e552003e687441bc0d2eb7e33feca47fb5e1d42b0
|