Simple logging module run on process with python logging
Project description
how to use
1. define configuration and call set_logger method to start logging process in main
from process_logging.logger import Logger, HandlerType
logger = Logger()
log_fime_name = "{:%Y-%m-%d}_info.log".format(datetime.now())
log_path = "./logs/"
trf_handler_args = {"filename": log_path + log_fime_name,
"when": "midnight",
"interval": 1,
"encoding": "utf-8"}
format_def = ("[%(levelname)s] | %(process)d | %(asctime)s | %(message)s", "%Y-%m-%d %H:%M:%S")
handler_def = {HandlerType.StreamHandler: {}, HandlerType.TimedRotateFileHandler: trf_handler_args}
if __name__ == "__main__":
logger.set_logger(name="logger", level=logging.INFO, handler_def=handler_def, format_def=format_def)
2. atfer set _logger, you can logging anywhere in your project with Logger()
@cbv(project_router)
class Router:
def __init__(self):
self._logger = Logger()
@project_router.get(PREFIX)
def test_func(self):
# logging
self._logger.logging(name="logger", level=logging.INFO, message="logging test")
3. result
[INFO] | 4147 | 2023-08-30 10:09:29 | logging test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
process_logging-0.2.0.tar.gz
(2.8 kB
view details)
Built Distribution
File details
Details for the file process_logging-0.2.0.tar.gz
.
File metadata
- Download URL: process_logging-0.2.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 769d21470fbdece9b1f58aacb81c410ce6dd68ddf98fd98a03a4de755be3a4ae |
|
MD5 | e1b51e03476db26af77919fabe80add3 |
|
BLAKE2b-256 | f81939c18dc2b54d968cf657220464df425b4f7dd88908b8261950b3bdf233af |
File details
Details for the file process_logging-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: process_logging-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf3b113605701f0b8c5146d36ac4155441feac81068a20654ab080ffab33b58c |
|
MD5 | 553bed7cc14c5655741b19a3303bd176 |
|
BLAKE2b-256 | bc1d30ed0a5cd8da5fb68e0332272b68c10aef68a432c37c87f57b4095eee5e8 |