A collection of helpful logging-functionality based on the logging package
Project description
SwiftGUI-Logging: Motivation
A small package ment to extend logging to better fit actual applications.
Before getting into the logging-package, I usually implemented something like this (but more complicated):
def main():
...
if __name__ == "__main__":
try:
main() # Run the main program
except Exception as ex: # An exception occured
with open("Crashlog.txt", "w") as f: # Save exception to file
f.write(str(ex))
If main() causes an exception, the file Crashlog.txt is created
containing information about the exception.
That means, only "the interesting logs" take up storage space.
Unfortunately, you can't implement such a functionality using the logging-package.
Until now.
SwiftGUI-Logging provides a very easy way to set up crashlogs that are fully compatible with the logging-package.
Basic usage
Installation
Install the package by running this on your terminal:
pip install SwiftGUI_Logging
Crashlogging to a file
Simply call SwiftGUI_Logging.Configs.exceptions_to_file(filepath)
to set up the crashlogger.
That's all.
Example:
import time
import SwiftGUI_Logging as sgl
import logging
def main():
for i in range(10):
logging.debug(f"Test {i}")
print(i)
time.sleep(0.25)
logging.info("Crashing the program now")
1 / 0 # Cause a ZeroDivisionError, which crashes the program
if __name__ == '__main__':
sgl.Configs.exceptions_to_file("Crashlogs/Crash.log") # Set up the crash-log
main() # Execute program
You'll find that the directory Crashlogs was created.
After the program executes, the directory contains a file like
Crash_2026-02-24_16-16-38.log.
As you can see, the time of the crash was inserted into the filename, so that multiple crashlogs don't overwrite each other.
sgl.Configs.exceptions_to_file can do a bit more, but for most programs,
the default configuration is fine.
Other functionality
SwiftGUI_Logging provides some other functionality, but these
aren't nearly as important as the exceptions_to_file-function.
A detailed documentation will follow.
SwiftGUI
This package was written as an addition to
my Python GUI-package SwiftGUI:
https://github.com/CheesecakeTV/SwiftGUI
Since SwiftGUI_Logging itself has nothing to to with GUIs,
it is its own package.
Consider checking out SwiftGUI if you want to easily create
user-interfaces for python.
If you already know the package PySimpleGUI, you'll learn the
basics ofSwiftGUI with little to no effort.
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 swiftgui_logging-0.1.1.tar.gz.
File metadata
- Download URL: swiftgui_logging-0.1.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.13.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b39e0b21d1b09bdba644fe049651ee957ac7e80b52b58707513b30fca2cad3fc
|
|
| MD5 |
bfe446a1853a4a9a8714a7a9d118a8ae
|
|
| BLAKE2b-256 |
2e0fb7a9d1245f6a55a0b34bf3c6cc4a7dabaaa8bd2fc59fd1182dfa84bc05ca
|
File details
Details for the file swiftgui_logging-0.1.1-py3-none-any.whl.
File metadata
- Download URL: swiftgui_logging-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.13.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2a7ebac08ee87e108dd42341d3ed576685c899e7a5895a41c92989370cf56e9
|
|
| MD5 |
52c921f20d01987869c6daa94d09ed42
|
|
| BLAKE2b-256 |
b3e1a48200e861b58f167fcb74ed7c6624d977b8e8de3af542db87d21f9a2e64
|