seed-papertrail
Some utilities to time things and log things.
>>> import logging
>>> formatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s] %(message)s")
>>> logger = logging.getLogger('papertrail')
>>> consoleHandler = logging.StreamHandler()
>>> consoleHandler.setFormatter(formatter)
>>> logger.addHandler(consoleHandler)
>>> logger.setLevel(logging.DEBUG)
Usage as a function decorator
>>> from seed_papertrail.decorators import papertrail
>>> @papertrail.warn
... def testing(): print 1
...
>>> testing()
1
2017-01-24 11:16:02,100 [MainThread ] [WARNI] __main__.testing 0.000021:
One can also specify a custom log message and a sample size argument:
>>> @papertrail.warn('this is likely to explode', sample=0.5)
... def testing(): print 1
...
>>> testing()
1
>>> testing()
1
>>> testing()
1
2017-01-24 11:38:56,068 [MainThread ] [WARNI] __main__.testing 0.000018: this is likely to explode
>>> testing()
1
2017-01-24 11:38:59,628 [MainThread ] [WARNI] __main__.testing 0.000019: this is likely to explode
>>> testing()
1
>>>
Usage as a context manager
>>> from seed_papertrail.decorators import papertrail
>>> with papertrail.timer('hulloo') as l:
... l.debug('more logging here!')
... print 1
...
2017-01-24 11:32:23,109 [MainThread ] [DEBUG] more logging here!
1
2017-01-24 11:32:23,115 [MainThread ] [DEBUG] 0.002581: hulloo, threshold:OK
>>>
You can also specify custom thresholds:
>>> with papertrail.timer('o_O', thresholds={'OK': (0, 0.1), 'FAIL': (0.1, 1000)}):
... time.sleep(6)
...
2017-01-24 11:45:00,717 [MainThread ] [DEBUG] 6.000664: o_O, threshold:FAIL
Addtionally the timer function allows one to specify the following keyword arguments:
level the logging level, defaults to DEBUG
logger the logger to log to, defaults to papertrail
Metadata
Release files for seed-papertrail 1.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| seed-papertrail-1.5.1.tar.gz | 8.9 kB | Without provenance | Details for seed-papertrail-1.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| seed_papertrail-1.5.1-py2-none-any.whl | Python 2 | none | any | Details for seed_papertrail-1.5.1-py2-none-any.whl |
Total release size: 15.4 kB
Release files / seed-papertrail-1.5.1.tar.gz
| Download URL | seed-papertrail-1.5.1.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03375e3e870fdb2216e54d8b2fbc06edeb8de005c4e47b479c79b4f0f3d84f0e
|
|
BLAKE2b-256 checksum How to use checksums |
5e82b16ba37fb2dc91ae00b6bd8c96ef6e7f0bcf2b8fa1f5e94abf248ea58da9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / seed_papertrail-1.5.1-py2-none-any.whl
| Download URL | seed_papertrail-1.5.1-py2-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
b9a3943045cd1fa00ec28add287dc90c4bb6a3e9be9740fa1b64aa45ae67f15d
|
|
BLAKE2b-256 checksum How to use checksums |
453380cf95ea8dc883b825b42d2e92d7684951d75247faa499fa72d7bae0becf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for seed-papertrail 1.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.