bestlog
this is a simple python logger that logs to file and stdout
I originally wanted to call it 'easylog' but there is already a package with that name on pypi
Install
$ pip install bestlog
Using
from bestlog import logger
import logging
log = logger.get("test")
# or
log = logging.getLogger("test")
def main():
log.info("what the fuck")
if __name__ == '__main__':
logger.init("test")
main()
output:
[2022-11-16 21:37:06,032][INFO]: what the fuck
you can find log file in the 'logs' folder of the current directory, one log file per day
Advance
from bestlog import logger
import logging
logger.default_log_path = "/var/log/test/"
logger.default_log_level = logging.DEBUG
logger.default_backup_days = 30
log = logger.get("test")
def main():
log.debug("what the fuck")
if __name__ == '__main__':
logger.init("test")
main()
you can specify the path to save the log file
you can set how many days the log file will be retained, default 0 is unlimited
With tag
from bestlog import logger
class Worker:
def __init__(self, name):
self.name = name
self.log = logger.get("test", name)
def do_something(self):
self.log.info("hello")
def main():
worker1 = Worker("bob")
worker2 = Worker("jack")
worker1.do_something()
worker2.do_something()
if __name__ == '__main__':
logger.init("test", tag = True)
main()
output:
[2022-11-16 21:42:49,469][INFO][bob]: hello
[2022-11-16 21:42:49,470][INFO][jack]: hello
you can distinguish between the logs of different workers based on their tag
Metadata
Release files for bestlog 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bestlog-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for bestlog-1.2.1-py3-none-any.whl |
Release files / bestlog-1.2.1-py3-none-any.whl
| Download URL | bestlog-1.2.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e168d95221182b4785d8ad08950b34312faf36a2c52322008f5abb46c6c1dbfb
|
|
BLAKE2b-256 checksum How to use checksums |
f454d2863a3a2af37fac46023460b5608f3ee120938ceae1946ecd6eb46682d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for bestlog 1.2.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.