delogger is a convenient logging package
Project description
delogger
About
Delogger is a Python package that makes easy use of decided logging.
Delogger
- It behaves like normal logging.
DeloggerQueue
- Non-blocking logging using QueueHandler.
Installation
To install Delogger, use pip.
pip install delogger
Sample
Debug stream and output log
from delogger.presets.debug import logger
if __name__ == "__main__":
logger.debug("debug msg")
logger.info("info msg")
logger.warning("warn msg")
logger.error("error msg")
logger.critical("critical msg")
Output
File output (./log/20201010_164622.log)
2020-10-10 16:46:22.050 DEBUG debug_preset.py:4 <module> debug msg
2020-10-10 16:46:22.050 INFO debug_preset.py:5 <module> info msg
2020-10-10 16:46:22.051 WARN debug_preset.py:6 <module> warn msg
2020-10-10 16:46:22.051 ERROR debug_preset.py:7 <module> error msg
2020-10-10 16:46:22.051 CRIT debug_preset.py:8 <module> critical msg
and more samples
Preset
debug
: Output color debug log and save log file.debug_stream
: Output color debug log.output
: Save log file and notify to slack.profiler
: Same debug preset and seted profiles decorator.
Mode
CountRotatingFileMode
: Backup count rotating.TimedRotatingFileMode
: Same logging.handlers.TimedRotatingFileHandler.SlackWebhookMode
: Log to slack. (Incomming webhook)SlackTokenMode
: Log to slack. (token key)StreamColorDebugMode
: Output color log. (debug and above)StreamDebugMode
: Output noncolor log. (debug and above)StreamInfoMode
: Output noncolor log. (info and above)PropagateMode
: Set Setropagate true.
Environment
DELOGGER_NAME
: logger name for presets.DELOGGER_FILEPATH
: output log filepath for presets.DELOGGER_SLACK_WEBHOOK
: send slack for presets.
Decorator
Inject decorator into logger.
debuglog
DEBUG 21:00:00 debug_log.py:32 START test args=('test',) kwargs={}
DEBUG 21:00:01 debug_log.py:39 END test return=value
line_profile
Required line_profiler package.
DEBUG 21:38:22 line_profile.py:28 line_profiler result
Timer unit: 1e-06 s
Total time: 6.4e-05 s
File: test.py
Function: test at line 6
Line # Hits Time Per Hit % Time Line Contents
==============================================================
6 @logger.line_profile
7 def test(arg1):
8 101 43.0 0.4 67.2 for i in range(100):
9 100 21.0 0.2 32.8 pass
10 1 0.0 0.0 0.0 return i
memory_profile
Required memory_profiler package.
DEBUG 21:40:31 memory_profile.py:25 memory_profiler result
Filename: test.py
Line # Mem usage Increment Line Contents
================================================
6 37.96 MiB 37.96 MiB @logger.memory_profile
7 def test(arg1):
8 45.43 MiB 7.47 MiB a = [0] * 1000 * 1000
9 45.43 MiB 0.00 MiB for i in range(100):
10 45.43 MiB 0.00 MiB pass
11 45.43 MiB 0.00 MiB return i
line_memory_profile
Required line_profiler and memory_profiler package.
DEBUG 21:41:08 line_memory_profile.py:70 line, memory profiler result
Timer unit: 1e-06 s
Total time: 0.004421 s
File: test.py
Function: test at line 6
Line # Hits Time Per Hit % Time Mem usage Increment Line Contents
=========================================================================================
6 37.96 MiB 37.96 MiB @logger.line_memory_profile
7 def test(arg1):
8 1 4355.0 4355.0 98.5 45.43 MiB 7.47 MiB a = [0] * 1000 * 1000
9 101 33.0 0.3 0.7 45.43 MiB 0.00 MiB for i in range(100):
10 100 32.0 0.3 0.7 45.43 MiB 0.00 MiB pass
11 1 1.0 1.0 0.0 45.43 MiB 0.00 MiB return i
add_line_profile
- It can adjust the timing of profile output
Required line_profiler package.
DEBUG 21:45:55 line_profile.py:67 line_profiler_stats result
Timer unit: 1e-06 s
Total time: 0.009081 s
File: test.py
Function: test at line 6
Line # Hits Time Per Hit % Time Line Contents
==============================================================
6 @logger.add_line_profile
7 def test(arg1):
8 2 8957.0 4478.5 98.6 a = [0] * 1000 * 1000
9 202 71.0 0.4 0.8 for i in range(100):
10 200 52.0 0.3 0.6 pass
11 2 1.0 0.5 0.0 return i
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
delogger-0.3.0.tar.gz
(14.4 kB
view details)
Built Distribution
delogger-0.3.0-py3-none-any.whl
(21.1 kB
view details)
File details
Details for the file delogger-0.3.0.tar.gz
.
File metadata
- Download URL: delogger-0.3.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.3 CPython/3.7.9 Linux/5.4.0-1026-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0bb133770541ba95bf60b714cc7ad656aab205ec80604e898271c854de44f1c |
|
MD5 | 2ddc036b198fcd528736df1c54fe9c4a |
|
BLAKE2b-256 | e429497a3ff25ce4c4c2275cfe8498e396ba3559957e86ea58d3cb86dba11a99 |
File details
Details for the file delogger-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: delogger-0.3.0-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.3 CPython/3.7.9 Linux/5.4.0-1026-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0bf10687175f95c501a7e56d5a657b0661603a70c11b26a9607aba87910798a |
|
MD5 | e9e38cba70689b073e053ea6fc645c3b |
|
BLAKE2b-256 | 8273dc3c18139f3f1d4818631a3613780ef767a52d6dec96f54bc5c242559f81 |