Skip to main content

Features that Python should have in the standard library

Project description

SuperPy

Downloads Downloads Downloads

There are 5 sub modules:

  • sp.logging
  • sp.testing
  • sp.concurrency
  • sp.dicts
  • sp.disk
  • sp.string

sp.logging

SuperPy's logging system is a simple abstraction from the standard library logging module. It also provides some nice extra functionalities. Here are some examples:

Logging messages

import super_py as sp

log = sp.logging.Logger("info",
    ts_color="bright_green",
    terminal=True,
    files=["info.log", "combined.log"],
)

log("This is a simple log!")

This will write the following log line to the terminal, and the files info.log and comnined.log:

[info        ] 2022-10-04 15:53:09            This is a simple log!

where the name and timestamp will be colored in bright_green.

Logging function benchmarks

You can also use the provided decorator to log benchmarks of your functions:

import super_py as sp

log = sp.logging.Logger("benchmark",
    ts_color="bright_green",
    terminal=True,
)

@log.benchmark(with_args=[0])
def wait(seconds):
    time.sleep(seconds)

for i in range(10):
    wait(i / 10)

This will write the following log lines:

[benchmark   ] 2022-10-04 16:03:39     0.0ms  wait((0.0))
[benchmark   ] 2022-10-04 16:03:39   105.1ms  wait((0.1))
[benchmark   ] 2022-10-04 16:03:39   205.1ms  wait((0.2))
[benchmark   ] 2022-10-04 16:03:40   308.3ms  wait((0.3))
[benchmark   ] 2022-10-04 16:03:40   403.5ms  wait((0.4))
[benchmark   ] 2022-10-04 16:03:40   505.1ms  wait((0.5))
[benchmark   ] 2022-10-04 16:03:41   605.1ms  wait((0.6))
[benchmark   ] 2022-10-04 16:03:42   705.1ms  wait((0.7))
[benchmark   ] 2022-10-04 16:03:43   804.1ms  wait((0.8))
[benchmark   ] 2022-10-04 16:03:43   903.3ms  wait((0.9))

You can use benchmark without calling the decorator, it will still work:

@log.benchmark
def wait(seconds):
    time.sleep(seconds)

The benchmark decorator takes the following keyword arguments:

  • with_args: list[int]: The list of indices of function arguments which should be logged.
  • with_kwargs: list[str]: The list of keyword argument names of the function which should be logged.

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

super-py-1.0.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

super_py-1.0.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file super-py-1.0.0.tar.gz.

File metadata

  • Download URL: super-py-1.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.7 Darwin/21.6.0

File hashes

Hashes for super-py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 98a40fb22157d09bc7b8e12597e38a1e2a766ab7cbd84af60985ff187a8e75a6
MD5 eea32c3226d29e13d4687a5d6c49869c
BLAKE2b-256 e9913582501d1cacda89e5ada29ebedc36cca4ad54cc7af10183027b826143e5

See more details on using hashes here.

File details

Details for the file super_py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: super_py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.7 Darwin/21.6.0

File hashes

Hashes for super_py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e658814befe7487ebbc176e4954a2bab6678dc773dfcbad06bb01933f80d4e91
MD5 ed7557ca75fa135298ce8154bd5d7ad6
BLAKE2b-256 d9252a0237f52c238fc65aab8570cc4c2ee29148b72026e5333679c0328bf604

See more details on using hashes here.

Supported by

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