Skip to main content

A relatively simple and good-looking logging library for Python, with relatively good customisability.

Project description

slofop

The hell is this name?

The name 'slofop' stands for 'Simple logger for Python'.

Showcase

After running the example.py file, ...

  • ...the terminal output is

Example script output

  • ...the content of 'test.log' is
DEBUG      MainThread   25.10.2022 17:00:49 CEST: {
                                                      "__name__": "__main__",
                                                      "__doc__": null,
                                                      "__package__": null,
                                                      "__loader__": "<_frozen_importlib_external.SourceFileLoader object at 0x7fab7107d510>",
                                                      "__spec__": null,
                                                      "__annotations__": {},
                                                      "__builtins__": "<module 'builtins' (built-in)>",
                                                      "__file__": "/run/media/paddecraft/4EE0F299E0F2870D/Dev/PythonScripting/slofop/example.py",
                                                      "__cached__": null,
                                                      "filesystem_handlers": "<module 'slofop.filesystem_handlers' from '/run/media/paddecraft/4EE0F299E0F2870D/Dev/PythonScripting/slofop/slofop/filesystem_handlers.py'>",
                                                      "util": "<module 'slofop.util' from '/run/media/paddecraft/4EE0F299E0F2870D/Dev/PythonScripting/slofop/slofop/util.py'>",
                                                      "slofop": "<module 'slofop.slofop' from '/run/media/paddecraft/4EE0F299E0F2870D/Dev/PythonScripting/slofop/slofop/slofop.py'>",
                                                      "Logger": "<class 'slofop.slofop.Logger'>",
                                                      "LoggingLevel": "<enum 'LoggingLevel'>",
                                                      "os": "<module 'os' from '/usr/lib/python3.10/os.py'>",
                                                      "time": "<module 'time' (built-in)>",
                                                      "atexit": "<module 'atexit' (built-in)>",
                                                      "pathlib": "<module 'pathlib' from '/usr/lib/python3.10/pathlib.py'>",
                                                      "threading": "<module 'threading' from '/usr/lib/python3.10/threading.py'>",
                                                      "NoneType": "<class 'NoneType'>",
                                                      "BaseFilesystemHandler": "<class 'slofop.filesystem_handlers.BaseFilesystemHandler'>",
                                                      "TimedFilesystemHandler": "<class 'slofop.filesystem_handlers.TimedFilesystemHandler'>",
                                                      "log": "Logger {colors: {DEBUG: [#c7dcff]#c7dcff[/#c7dcff], INFO: [#3caae6]#3caae6[/#3caae6], WARNING: [#e0c528]#e0c528[/#e0c528], ERROR: [#e61c5b]#e61c5b[/#e61c5b], CRITICAL: [#f50a19]#f50a19[/#f50a19]}, filesystem_handler: FilesystemHandler(BaseFilesystemHandler), level: LoggingLevel.DEBUG, file: ./test.log}"
                                                  }
INFO       MainThread   25.10.2022 17:00:49 CEST: Info
WARNING    MainThread   25.10.2022 17:00:49 CEST: Warn
ERROR      MainThread   25.10.2022 17:00:49 CEST: Error
CRITICAL   MainThread   25.10.2022 17:00:49 CEST: Critical
DEBUG      Thread-1     25.10.2022 17:00:49 CEST: Running in Thread-1 (testThread)
INFO       Thread-1     25.10.2022 17:00:49 CEST: Thread running time 1
DEBUG      Thread-1     25.10.2022 17:00:50 CEST: Running in Thread-1 (testThread)
INFO       Thread-1     25.10.2022 17:00:50 CEST: Thread running time 2
DEBUG      Thread-1     25.10.2022 17:00:51 CEST: Running in Thread-1 (testThread)
INFO       Thread-1     25.10.2022 17:00:51 CEST: Thread running time 3
DEBUG      Thread-1     25.10.2022 17:00:52 CEST: Running in Thread-1 (testThread)
INFO       Thread-1     25.10.2022 17:00:52 CEST: Thread running time 4

Class tree

class slofop.Logger:
    def __init__(
        self,
        logfile_path: str = None,
        show_threads: bool = True,
        level: LoggingLevel = LoggingLevel.INFO,
        colors: ColorFormat = {
            LoggingLevel.DEBUG: "#c7dcff",
            LoggingLevel.INFO: "#3caae6",
            LoggingLevel.WARNING: "#e0c528",
            LoggingLevel.ERROR: "#e61c5b",
            LoggingLevel.CRITICAL: "#f50a19",
        },
        time_format_file: str = "%d.%m.%Y %H:%M:%S",
        time_format_console: str = "%H:%M:%S",
        filesystem_handler: Type[BaseFilesystemHandler] = BaseFilesystemHandler(
        ),
    ) -> None

    def debug(*elements) -> None
    def info(*elements) -> None
    def warn(*elements) -> None
    def error(*elements) -> None
    def critical(*elements) -> None

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

slofop-0.3.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

slofop-0.3.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file slofop-0.3.0.tar.gz.

File metadata

  • Download URL: slofop-0.3.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.7 Linux/5.15.0-1022-azure

File hashes

Hashes for slofop-0.3.0.tar.gz
Algorithm Hash digest
SHA256 fca54af40aa6ae548ad48cf160a005a82d02eafa78e18d19c4ddb338a9b02c12
MD5 1e346f95f81e24bfcbfca6868e4d2147
BLAKE2b-256 3eeb6307c0ce696a8cec967bf68853cda39f357352c1b78ac67ade064a1ee8d4

See more details on using hashes here.

File details

Details for the file slofop-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: slofop-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.7 Linux/5.15.0-1022-azure

File hashes

Hashes for slofop-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f85f859e2d1a8b92d0960fe0a9689f56475bbd511a956a0eb5fbc7517aa05c6e
MD5 edf6f604dae05e1d1ad5b19c93ac976c
BLAKE2b-256 048b122f9bb9f29d6f9ca1f264e040714fd80a8a40491efe417ec2ed36a2d846

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page