A simple global logging wrapper library
Project description
Simple Global Logging
A simple Python logging extension library that enhances the standard logging functionality with global configuration and stdout capture capabilities.
Features
- Global Logging Setup: Initialize once, use everywhere with standard
import logging - Automatic File Output: Logs saved to timestamped files in
out/directory - Standard Output Capture: Capture console output to log files
- pytest Integration: Capture pytest output via conftest.py
- Configurable Timezone: All timestamps in specified timezone (default: UTC)
[!IMPORTANT] This library clears all existing handlers from the root logger and its children during initialization. If your application uses other logging handlers, make sure to:
- Initialize this library before setting up other handlers
- Or manually re-add your handlers after initialization
Installation
pip install simple-global-logging
Quick Start
import simple_global_logging
import logging
# Basic setup
simple_global_logging.setup_logging(verbose=True)
logging.info("This will be logged to file and console")
# With stdout capture
simple_global_logging.setup_logging_with_stdout_capture()
print("This will also be logged")
API Reference
Core Functions
# Basic logging setup
setup_logging(
verbose=False, # Enable DEBUG level if True
base_dir="out", # Log directory
tz=None # Timezone (default: UTC)
)
# With stdout capture
setup_logging_with_stdout_capture(
verbose=False,
base_dir="out",
remove_ansi=True, # Remove terminal color codes
tz=None
)
# Utility functions
get_logger(name) # Get logger instance
restore_stdout() # Restore original stdout
get_current_log_file() # Get current log file path
get_current_timezone() # Get current timezone
Log File Format
- Location:
out/directory (customizable) - Filename:
YYYYMMDD-0000001.log(7-digit sequential number) - Content: Timestamps in specified timezone
Examples
The library includes example scripts in the examples/ directory:
basic_usage.py: Basic logging setupstdout_capture_example.py: Output capturesubmodule.py: Logging from different modulestimezone_example.py: Timezone configuration
For pytest integration, see conftest_template.py in the tests/ directory.
Requirements
- Python 3.10 or higher
Development
This library was developed using Cursor, a modern AI-powered IDE.
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
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 simple_global_logging-0.1.1.tar.gz.
File metadata
- Download URL: simple_global_logging-0.1.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a3b0441dd4ee8a37b9f1e97e4513d1f0ba06bb3baad8557f5b8059501f73388
|
|
| MD5 |
21eb5aed2ab2db56e0a7b68a86ce6b3d
|
|
| BLAKE2b-256 |
845cf176c988513f376ff3976657c6b0ee86b97865d7cd01037f65670b2d51f3
|
Provenance
The following attestation bundles were made for simple_global_logging-0.1.1.tar.gz:
Publisher:
publish-pypi.yml on hasegama/simple-global-logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_global_logging-0.1.1.tar.gz -
Subject digest:
3a3b0441dd4ee8a37b9f1e97e4513d1f0ba06bb3baad8557f5b8059501f73388 - Sigstore transparency entry: 230964742
- Sigstore integration time:
-
Permalink:
hasegama/simple-global-logging@3c2da18fe886ab4dfd8efa6d11ad7680d87624f2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/hasegama
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@3c2da18fe886ab4dfd8efa6d11ad7680d87624f2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file simple_global_logging-0.1.1-py3-none-any.whl.
File metadata
- Download URL: simple_global_logging-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.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 |
f7364a102f3a5a80bae8d7db5403981d2720ab8d988dc46ac52902fa77180397
|
|
| MD5 |
f65521bfe626ad02d8be600563600660
|
|
| BLAKE2b-256 |
53d952d730f17069a2550e6c18dcabead9e40f2f0fba33a47c0f2cd8449c3ec8
|
Provenance
The following attestation bundles were made for simple_global_logging-0.1.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on hasegama/simple-global-logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_global_logging-0.1.1-py3-none-any.whl -
Subject digest:
f7364a102f3a5a80bae8d7db5403981d2720ab8d988dc46ac52902fa77180397 - Sigstore transparency entry: 230964755
- Sigstore integration time:
-
Permalink:
hasegama/simple-global-logging@3c2da18fe886ab4dfd8efa6d11ad7680d87624f2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/hasegama
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@3c2da18fe886ab4dfd8efa6d11ad7680d87624f2 -
Trigger Event:
release
-
Statement type: