baodebug 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
baodebug/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import debugutils
|
baodebug/debugutils.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import cv2
|
|
3
|
+
import os
|
|
4
|
+
import shutil
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def SetDebugPath(debug_path):
|
|
8
|
+
if os.path.exists(debug_path):
|
|
9
|
+
shutil.rmtree(debug_path)
|
|
10
|
+
os.makedirs(debug_path, exist_ok=False)
|
|
11
|
+
os.environ['DEBUG_PATH'] = debug_path
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
logLevelMap = {
|
|
15
|
+
"debug": logging.DEBUG,
|
|
16
|
+
"info": logging.INFO,
|
|
17
|
+
"warning": logging.WARNING,
|
|
18
|
+
"error": logging.ERROR,
|
|
19
|
+
"critical": logging.CRITICAL
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ColorFormatter(logging.Formatter):
|
|
24
|
+
|
|
25
|
+
grey = "\x1b[38;20m"
|
|
26
|
+
yellow = "\x1b[33;20m"
|
|
27
|
+
green = "\x1b[32;20m"
|
|
28
|
+
cyan = "\x1b[36;20m"
|
|
29
|
+
blue = "\x1b[34;20m"
|
|
30
|
+
red = "\x1b[31;20m"
|
|
31
|
+
reset = "\x1b[0m"
|
|
32
|
+
format = "%(asctime)s - %(name)s - %(levelname)s - (%(filename)s:%(lineno)d): %(message)s"
|
|
33
|
+
|
|
34
|
+
FORMATS = {
|
|
35
|
+
logging.DEBUG: blue + format + reset,
|
|
36
|
+
logging.INFO: green + format + reset,
|
|
37
|
+
logging.WARNING: yellow + format + reset,
|
|
38
|
+
logging.ERROR: red + format + reset,
|
|
39
|
+
logging.CRITICAL: cyan + format + reset
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
def format(self, record):
|
|
43
|
+
log_fmt = self.FORMATS.get(record.levelno)
|
|
44
|
+
formatter = logging.Formatter(log_fmt)
|
|
45
|
+
return formatter.format(record)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def ConfigureRootLogger(logLevel):
|
|
49
|
+
"""
|
|
50
|
+
configure the root logger formats and handlers.
|
|
51
|
+
"""
|
|
52
|
+
rootLogger = logging.getLogger()
|
|
53
|
+
rootLogger.setLevel(logLevelMap[logLevel.lower()])
|
|
54
|
+
|
|
55
|
+
consoleHandler = logging.StreamHandler()
|
|
56
|
+
consoleHandler.setLevel(logLevelMap[logLevel.lower()])
|
|
57
|
+
consoleFormatter = ColorFormatter()
|
|
58
|
+
consoleHandler.setFormatter(consoleFormatter)
|
|
59
|
+
|
|
60
|
+
rootLogger.addHandler(consoleHandler)
|
|
61
|
+
|
|
62
|
+
rootLogger.critical("(set up root logger..)")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def dump_image(image, path):
|
|
66
|
+
cv2.imwrite(path, image)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: baodebug
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An simple Python package for debug
|
|
5
|
+
Author-email: Runqiu Bao <bao@robot.t.u-tokyo.ac.jp>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: dumpvisz,logging
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
## Python usage
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
import baodebug
|
|
19
|
+
|
|
20
|
+
baodebug.debugutils.ConfigureRootLogger("info") # config logger format
|
|
21
|
+
baodebug.debugutils.SetDebugPath("/root/visz/") # create debug folder here and set to os.environ["DEBUG_PATH"]
|
|
22
|
+
|
|
23
|
+
import logging
|
|
24
|
+
logger = logging.getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
logger.info("this will be printed in green")
|
|
27
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
baodebug/__init__.py,sha256=2-cra4HGNhMhgrwvg87B07xUvbkG_YNgtTavLD50hpc,24
|
|
2
|
+
baodebug/debugutils.py,sha256=3LN6KPgjjlYHPFtFT71YVPBuxZ_LTiHU5OTgu3f3zUs,1698
|
|
3
|
+
baodebug-0.1.0.dist-info/METADATA,sha256=QxZ71evv96Js5lJqRVOfnWThSiHYxNDpdXwjGFg8bVk,757
|
|
4
|
+
baodebug-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
5
|
+
baodebug-0.1.0.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
baodebug-0.1.0.dist-info/RECORD,,
|
|
File without changes
|