MWK logger
Custom logger with colors on terminal.
And some useful decorators.
Installing package
pip install mwk-logger
Using logger
1. Get instance of mwk-logger
from mwk_logger import MwkLogger
log = MwkLogger(name='mwk',
file='logger.log',
stream_level='DEBUG',
file_level='DEBUG',
time=True)
keyword parameters:
- name - name of the logger, by default = 'mwk',
- file - path to file to log into, by default = 'mwk.log',
- stream_level - logging level for terminal, by default = 'WARNING',
- file_level - logging level for file, by default = None,
- time - if timestamp should be added to terminal log, by default = False,
LEVELS:
None - no logging or:
'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'.
If both levels are set to None stream_level is changed to WARNING.
Timestamp is always added to file logs. One can set if timestamp will be added to terminal logs.
2. Logging
log.debug('This is a debug message.')
log.info('This is an info message.')
log.warning('This is a warning message.')
log.error('This is an error message!')
log.critical('This is a critical message!!!')
log.exception('This is an exception message!')
Using decorators
- @timer - print or log the runtime of the decorated function
- @f_sig - print or log the signature and the return value of the decorated function
1. Decorator with no arguments
Prints on screen.
from mwk_logger import timer, f_sig
@timer
@f_sig
def function(*args, **kwargs):
# ... some function ...
return 'something'
1. Decorator with arguments
Output is logged with provided logger with level = INFO.
!!! keyword logger is obligatory !!!
from mwk_logger import MwkLogger, timer, f_sig
log = MwkLogger()
@timer(logger=log)
@f_sig(logger=log)
def function(*args, **kwargs):
# ... some function to be logged...
return 'something'
Metadata
Release files for mwk-logger 2.0.4
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 |
|---|---|---|---|---|
| mwk-logger-2.0.4.tar.gz | 5.7 kB | Without provenance | Details for mwk-logger-2.0.4.tar.gz |
Release files / mwk-logger-2.0.4.tar.gz
| Download URL | mwk-logger-2.0.4.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59e71d0e59706d71314e1231f5b2febacdbe4994834f1368494c3894a90f1f78
|
|
BLAKE2b-256 checksum How to use checksums |
90313a42bc79e64e75e6841e0f2fb27b2627dfd6d250f08bdf209871de52d958
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Security for mwk-logger 2.0.4
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.