netlink-logging
Part of the NetLink Python Tools
A small wrapper around python logging and logzero.
Features
- Log to a logfile automatically (same name as the top-level script,
_input_for console) - Additional levels:
TRACE(5)VERBOSE(15)SUCCESS(25)
- Timestamps are in UTC and use format
%Y-%m-%d %H:%M:%S - Uncaught Exceptions are logged as
CRITICAL
Installation
pip install netlink-logging
Usage
from netlink.logging import logger
logger.trace('A TRACE entry.')
logger.debug('A DEBUG entry.')
logger.verbose('A VERBOSE entry.')
logger.info('An INFO entry.')
logger.success('A SUCCESS entry.')
logger.warning('A WARNING entry.')
logger.error('An ERROR entry.')
logger.critical('A CRITICAL entry.')
results in
[D 2022-02-32 26:27:28 <input>:…] A DEBUG entry.
[V 2022-02-32 26:27:28 <input>:…] A VERBOSE entry.
[I 2022-02-32 26:27:28 <input>:…] An INFO entry.
[S 2022-02-32 26:27:28 <input>:…] A SUCCESS entry.
[W 2022-02-32 26:27:28 <input>:…] A WARNING entry.
[E 2022-02-32 26:27:28 <input>:…] An ERROR entry.
[C 2022-02-32 26:27:28 <input>:…] A CRITICAL entry.
Additional Methods
set_file
Use set_file to change the file that is logged to:
logger.set_file([filename,
[formatter,]
[mode,]
[max_bytes,]
[backup_count,]
[encoding,]
[log_level,]
[disable_stderr_logger]])
Parameters
-
filename (optional,
str)Must be provided, if any other parameter is provided. If not provided, or set to
Nonelogging to file is disabled. -
formatter (optional,
logging.Formatter)Formatter to use for logging to file. Defaults to
[K time module:line number] (message, where- K is the first letter of the logging level
- time is
%Y-%m-%d %H:%M:%Sin UTC - module and **line number show the location in code
- message as provided in call
-
mode (optional,
str)Mode to open the file with. Defaults to
a. -
max_bytes (optional,
int)Size of the logfile when rollover should occur. If set to
0, rollover never occurs. Defaults to100 MB. -
backup_count (optional,
int)Number of backups to keep. If set to 0, rollover never occurs. Defaults to
5. -
encoding (optional,
str)Used to open the file with that encoding. Defaults to
utf-8. -
log_level (optional,
int)Set a custom logging level for the file logger. Defaults to the current logging level.
-
disable_stderr_logger (optional,
bool)Should the default stderr logger be disabled. Defaults to
False.
set_level
The current logging level can be set without additional imports:
from netlink.logging import logger
logger.set_level(logger.ERROR)
enable_file
Enable logging to file, if it was disabled. Takes boolean.
disable_file
Disable logging to file.
hide_location
Hide module name and line number.
show_threading
Show thread name.
hide_threading
Hide thread name.
Changes
0.1.10
Option to show or hide thread name
Roadmap
An additional feature that is considered would log every Exception raised.
License
MIT License
Copyright (c) 2022 Bernhard Radermacher
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Metadata
Release files for netlink-logging 0.1.15
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 |
|---|---|---|---|---|
| netlink-logging-0.1.15.tar.gz | 5.8 kB | Without provenance | Details for netlink-logging-0.1.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netlink_logging-0.1.15-py3-none-any.whl | Python 3 | none | any | Details for netlink_logging-0.1.15-py3-none-any.whl |
Total release size: 12.2 kB
Release files / netlink-logging-0.1.15.tar.gz
| Download URL | netlink-logging-0.1.15.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
32690124514684d8038090738e2aa7814be9e8d6da01cf07f792a12183e9435b
|
|
BLAKE2b-256 checksum How to use checksums |
aeda68ff3f6d5aac995f7fce703cec56b44e52b1d2bf98aa8d8e402a4c8bb548
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.10 Windows/10
|
Release files / netlink_logging-0.1.15-py3-none-any.whl
| Download URL | netlink_logging-0.1.15-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dbd9e46459d942d851fae2dbee50e1af7c1a4899391ba979d8cbc70628f13b1c
|
|
BLAKE2b-256 checksum How to use checksums |
bc539a76b04204d6e6d6edc22cb3e45ab3e77ff612aaf6d2694d774726290fc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.10 Windows/10
|
Security for netlink-logging 0.1.15
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.