Shared utilities for logging and configuration management
Project description
Spello Consulting Utility Library
A Python utility library for log file management and YAML configuration file management
Details to follow
Example code
import sys
from config_schemas import ConfigSchema
from sc_utility import SCConfigManager, SCLogger
CONFIG_FILE = "config.yaml"
def main():
print("Hello from sc-utility!")
# Get our default schema, validation schema, and placeholders
schemas = ConfigSchema()
# Initialize the SC_ConfigManager class
try:
config = SCConfigManager(
config_file=CONFIG_FILE,
default_config=schemas.default, # Replace with your default config if needed
validation_schema=schemas.validation, # Replace with your validation schema if needed
placeholders=schemas.placeholders # Replace with your placeholders if needed
)
except RuntimeError as e:
print(f"Configuration file error: {e}", file=sys.stderr)
return
config_value = config.get("AmberAPI", "APIKey", default="this is the default value")
if config_value is None:
print("Configuration value not found")
else:
print(f"Configuration loaded successfully. Sample value: {config_value}")
# Initialize the SC_Logger class
try:
logger = SCLogger(config.get_logger_settings())
except RuntimeError as e:
print(f"Logger initialisation error: {e}", file=sys.stderr)
return
logger.log_message("This is a test message at the debug level.", "debug")
# logger.log_message("This is a test message at the error level.", "error")
# Setup email
email_settings = config.get_email_settings()
logger.register_email_settings(email_settings)
if logger.send_email("Hello world", "This is a test email from the sc-utility test harness."):
logger.log_message("Email sent OK.", "detailed")
if logger.get_fatal_error():
print("Prior fatal error detected.")
logger.clear_fatal_error()
# logger.log_fatal_error("This is a test fatal error message.")
logger.clear_fatal_error()
if __name__ == "__main__":
main()
Exceptions
The initialisation functions throw RuntimeError exceptions if a fatal error is encountered.
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 sc_utility-1.1.5.tar.gz.
File metadata
- Download URL: sc_utility-1.1.5.tar.gz
- Upload date:
- Size: 12.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 |
e93ff34397bd686738bcb62260533098e316823a81f309ba8bd5a9987e3f1688
|
|
| MD5 |
333502764ae37f6bfa08926ef21b891a
|
|
| BLAKE2b-256 |
a0fb5eecee6c65cda1b44113986c730f795d0da5a1d515ffdbb750d9f4409c92
|
Provenance
The following attestation bundles were made for sc_utility-1.1.5.tar.gz:
Publisher:
publish.yml on NickElseySpelloC/sc_utility
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sc_utility-1.1.5.tar.gz -
Subject digest:
e93ff34397bd686738bcb62260533098e316823a81f309ba8bd5a9987e3f1688 - Sigstore transparency entry: 233797937
- Sigstore integration time:
-
Permalink:
NickElseySpelloC/sc_utility@06e9e09b1f8a05da5daef82a4126e01e27195c6e -
Branch / Tag:
refs/tags/v1.1.5 - Owner: https://github.com/NickElseySpelloC
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06e9e09b1f8a05da5daef82a4126e01e27195c6e -
Trigger Event:
push
-
Statement type:
File details
Details for the file sc_utility-1.1.5-py3-none-any.whl.
File metadata
- Download URL: sc_utility-1.1.5-py3-none-any.whl
- Upload date:
- Size: 13.2 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 |
0de16e39a69ba294f8fadaf15398670b786d9094b4c94318d394d7dc65efb2da
|
|
| MD5 |
03f7f94dd01cb6b2214ae35d2c02ef06
|
|
| BLAKE2b-256 |
7c9e2d32b2876854917c730aa6402084a385b08f72612f36093e5ee8d4c6546c
|
Provenance
The following attestation bundles were made for sc_utility-1.1.5-py3-none-any.whl:
Publisher:
publish.yml on NickElseySpelloC/sc_utility
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sc_utility-1.1.5-py3-none-any.whl -
Subject digest:
0de16e39a69ba294f8fadaf15398670b786d9094b4c94318d394d7dc65efb2da - Sigstore transparency entry: 233797938
- Sigstore integration time:
-
Permalink:
NickElseySpelloC/sc_utility@06e9e09b1f8a05da5daef82a4126e01e27195c6e -
Branch / Tag:
refs/tags/v1.1.5 - Owner: https://github.com/NickElseySpelloC
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06e9e09b1f8a05da5daef82a4126e01e27195c6e -
Trigger Event:
push
-
Statement type: