quick_logger
A simple interface for the standard Python logging library.
About
This is a very simple package designed to setup a logger in one line and allow logging to it with ease.
Note
I wrote this package when I was still in school. It's really no easier than just using logger.<level>.
However, the init_logger method may still be of some use. I've updated it such that mlog can now
be dispatched with level:
from quick_logger import mlog
# Previously any level beyond info:
mlog("Here's a debug message.", "debug")
# Now, can use the same idiom as `logger.<level>`:
mlog.debug("Here's a debug message.")
Note that the original syntax is still backward-compatible, on the offchace anything out there uses this.
Ultimately, this package is very simple, you probably just want to use the base Python logging library.
Installation
Use pip to install.
python -m pip install quick_logger
Usage
Use init_logger to create a log file, and mlog to add a log entry.
Quick Start
init_logger
from quick_logger import init_logger, mlog
init_logger('/path/to/file.log')
By default, the log file will be set to logging.INFO.
mlog
# By default logs are set to "info"
mlog("Logged something!")
# Invoke by level
mlog.error("Something went wrong!")
It's that easy!
"Advanced" Setup
You can set a few options when you use init_logger.
level: Defaults toinfo, acceptscritical,error,warning,info,debug,notset.fmt: Defaults to'%(asctime)s:: %(levelname)s:: %(message)s'. See logging.Formatter for details on how to set aFormatterstring.datefmt: Defaults to'%Y-%m-%d %H:%M:%S'. See strftime reference.
from quick_logger import init_logger
# Log file set to debug
init_logger('/path/to/file.log', level='debug')
...
# Log file with fmt that includes module.
fmt = '%(asctime)s:: %(module)s:: %(message)s'
# or log file with fmt that just has messages.
fmt = '%(message)s'
init_logger('/path/to/file.log', fmt=fmt)
...
# Omit date, just include the time.
init_logger('/path/to/file.log', datefmt='%H:%M:%S')
Issues/Suggestions
Please make any suggestions or issues on the Github page. Note that this package is meant to be simple, so suggestions should keep that in mind.
License
This project is licensed under the MIT License. Please see the LICENSE.md file for details.
Release files for quick-logger 0.2.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 | |
|---|---|---|---|
| quick_logger-0.2.0.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| quick_logger-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / quick_logger-0.2.0.tar.gz
| Download URL | quick_logger-0.2.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f294e304f192a5ac7171d458d03270359c83938e9f9fec369134ac8cc2d46b4
|
|
BLAKE2b-256 checksum How to use checksums |
24c70a870734c96540a2041bbfd35f8b0261321185aedc717a3969d5586ef09a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.9.6 Windows/10
|
Release files / quick_logger-0.2.0-py3-none-any.whl
| Download URL | quick_logger-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a0f316230d31f8481f2bd1524d50734254c954cae7048a6025ced3e9e3c70657
|
|
BLAKE2b-256 checksum How to use checksums |
f96436a63498307f9db8c52f33dcbf76dcd3516dbe5766b21b040f0afa419f48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.9.6 Windows/10
|