py_logging_extensions
a wrapper to provide advanced logging capability with a simple call
Provides:
- coloured logging (If colorama installed)
- Log to file
- configuration file is generated for log formats and colours
- different log format for levels of logging.DEBUG and below
- TRACE logging level added as a level below logging.DEBUG (set to 5)
Basic Usage
import logging
# Import and setup the logger
from log_ext import setup_logger
setup_logger()
# Create a normal logging instance, and use as per normal docs
logger = logging.getLogger('ExampleLogger')
logger.setLevel(logging.DEBUG)
logger.debug('MyDebugMessage')
setup_logger
setup_logger(
name='log',
base_logger=None,
log_dir='logs',
cfg_file='log.yaml',
config={
'date_fmt_str': '%Y-%m-%d_%H:%M:%S',
'format_str': '%(asctime)17s-%(name)-12s-%(levelname)-8s-%(message)s',
'detailed_format_str': '(%(module)s-%(funcName)s #%(lineno)d)',
'colors': {
'TRACE': 'Back.WHITE,Fore.BLACK',
'DEBUG': 'Fore.CYAN',
'INFO': 'Fore.GREEN',
'WARNING': 'Fore.YELLOW',
'ERROR': 'Fore.RED',
'CRITICAL': 'Back.RED,Fore.WHITE'
}
},
trace_logging=True,
clear_others=False,
handles=None)
Setup a logger (call instead of logging.basicConfig)
:param name: (String) log file name
:param base_logger: (logging.Logger) logger to base off - uses root if not set
:param log_dir: (string | False) directory to store log files in - doesn't log to file if set to False
:param cfg_file: (string | False) configuration file to use, or false to skip creating a file
:param config: (Dict) configuration dictionary see CONFIG variable for example
:param trace_logging: (Bool) use trace logging
:param clear_others: (Bool) clear existing handlers on the base logger
:param handles: (List) also add these handlers to the base logger
:returns None
Notes
Pyinstaller
If using pyinstaller, make sure to provide paths suitable for your install path for log_dir and cfg_file - if you are using them.
clearing handlers
set clear_others to true to clear any existing handlers.
Log file
set log_dir to false to avoid logging to file.
Metadata
Release files for log-ext 1.1.0
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 |
|---|---|---|---|---|
| log_ext-1.1.0.tar.gz | 4.2 kB | Without provenance | Details for log_ext-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| log_ext-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for log_ext-1.1.0-py3-none-any.whl |
Total release size: 9.7 kB
Release files / log_ext-1.1.0.tar.gz
| Download URL | log_ext-1.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7df42efe37a1089b6e5c9f237512673695b8eef882acf46f49f8c515d9127f07
|
|
BLAKE2b-256 checksum How to use checksums |
106bf62d058436f9ceecbc399e1393d2309ec142fe405945460732386627da2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.3
|
Release files / log_ext-1.1.0-py3-none-any.whl
| Download URL | log_ext-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1ca4d4cdfcebc9620ec727dd4d4bddb30f202b6872f3af4553faff1b223695d
|
|
BLAKE2b-256 checksum How to use checksums |
7a131d4a3dd8b6535f840b4e3924190fa7a0a8fbe5e3d80bd2cdb6153bbe63e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.3
|
Security for log-ext 1.1.0
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.