A Python library for local logging with advanced features
Project description
loglocal
loglocal is a Python library for advanced local logging, built on top of loguru and pydantic. It provides configurable logging with support for both synchronous and asynchronous function decorators, file rotation, retention, and more.
Features
- Easy-to-use logger with sensible defaults
- Configurable via environment variables and pydantic models
- Supports both console and file logging
- Decorators for logging function execution (sync and async)
- File rotation, retention, compression, and serialization
Installation
You can install loglocal via pip:
pip install loglocal
Or if you prefer to use uv (Universal Virtual Environment):
uv add loglocal
Usage
from loglocal import logger
logger.info("Hello from loglocal!")
@logger.wrap
def my_function(x, y):
return x + y
@logger.wrap
async def my_async_function(x, y):
return x * y
API Reference
logger
A class-level property that returns a configured LogLocal instance using default settings.
LogLocal
Extends loguru.Logger with additional configuration and decorators.
Methods
-
from_config(config: LogLocalConfig, **kwargs) -> LogLocal
Create a logger instance from aLogLocalConfigobject. -
wrap(func=None)
Decorator to log execution of sync or async functions.
Example
from loglocal import Logger, logger
from loglocal.models import LogLocalConfig
custom_logger = Logger(
config=LogLocalConfig(
... # Custom configuration parameters
)
)
logger.info("Logging with default config")
Configuration
Environment Variables
LOGLOCAL_PATH: Path to the log file (default:logs/app.log)
You can customize logging behavior by passing a custom LogLocalConfig:
log_path: Path to log file (default:logs/app.log) # overridesLOGLOCAL_PATHenvironment variablelog_format: Log message formatlog_level: Logging level (default:DEBUG)log_opt: Additional options for the logger (e.g.,exception,depth,colors, etc.) of typeLogLocalOptionslog_config: Pydantic model for additional configuration options (e.g., file rotation, retention, compression, etc.) of typeLogConfig
License
MIT
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 loglocal-1.0.2.tar.gz.
File metadata
- Download URL: loglocal-1.0.2.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
053779db5967bb830592b7f4799dfc28b55bc00cba694a8817e673369fd2f3a3
|
|
| MD5 |
25abe44250f81775f7ecedc2ff8d9660
|
|
| BLAKE2b-256 |
8fc168807876e2f5113840840d4b171c2646920bc004396cb1a55ef0b58e3928
|
Provenance
The following attestation bundles were made for loglocal-1.0.2.tar.gz:
Publisher:
publish.yml on sabadia/loglocal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
loglocal-1.0.2.tar.gz -
Subject digest:
053779db5967bb830592b7f4799dfc28b55bc00cba694a8817e673369fd2f3a3 - Sigstore transparency entry: 302889980
- Sigstore integration time:
-
Permalink:
sabadia/loglocal@c48726b53eaa13916bd110ec81c0596d620b0973 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/sabadia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c48726b53eaa13916bd110ec81c0596d620b0973 -
Trigger Event:
release
-
Statement type:
File details
Details for the file loglocal-1.0.2-py3-none-any.whl.
File metadata
- Download URL: loglocal-1.0.2-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9f6a20516f5979cb1f9029eb338cecd6286b168f9231c2dccf2163ddd92497b
|
|
| MD5 |
482bb7ce5e500a6fa9599df14169ad04
|
|
| BLAKE2b-256 |
29f3f9bc8431e3bdd01d7226cd19c9d41b8b0fdb8aa85f063ea89c145766d713
|
Provenance
The following attestation bundles were made for loglocal-1.0.2-py3-none-any.whl:
Publisher:
publish.yml on sabadia/loglocal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
loglocal-1.0.2-py3-none-any.whl -
Subject digest:
a9f6a20516f5979cb1f9029eb338cecd6286b168f9231c2dccf2163ddd92497b - Sigstore transparency entry: 302890012
- Sigstore integration time:
-
Permalink:
sabadia/loglocal@c48726b53eaa13916bd110ec81c0596d620b0973 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/sabadia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c48726b53eaa13916bd110ec81c0596d620b0973 -
Trigger Event:
release
-
Statement type: