|
19 | 19 | import logging |
20 | 20 | import os |
21 | 21 |
|
22 | | -__all__ = [ |
23 | | - "debug", |
24 | | - "error", |
25 | | - "fatal", |
26 | | - "info", |
27 | | - "level", |
28 | | - "logger", |
29 | | - "log", |
30 | | - "warning", |
31 | | - "Logger", |
32 | | -] |
33 | | - |
34 | 22 |
|
35 | 23 | class Logger(object): |
36 | 24 | """Logger class.""" |
@@ -79,60 +67,68 @@ def _pretty_dict(value, indent=0): |
79 | 67 | return repr(value) |
80 | 68 |
|
81 | 69 |
|
| 70 | +level = Logger().get_logger().level |
| 71 | +DEBUG = logging.DEBUG |
| 72 | + |
| 73 | + |
82 | 74 | def log(level, msg, *args, **kwargs): |
83 | 75 | """Output log with the level as a parameter.""" |
84 | 76 | if isinstance(msg, dict): |
85 | 77 | for _, line in enumerate(_pretty_dict(msg).split("\n")): |
86 | | - Logger().get_logger().log(level, line, *args, **kwargs, stacklevel=2) |
| 78 | + Logger().get_logger().log(level, line, *args, **kwargs) |
87 | 79 | else: |
88 | | - Logger().get_logger().log(level, msg, *args, **kwargs, stacklevel=2) |
| 80 | + Logger().get_logger().log(level, msg, *args, **kwargs) |
89 | 81 |
|
90 | 82 |
|
91 | 83 | def debug(msg, *args, **kwargs): |
92 | 84 | """Output log with the debug level.""" |
93 | 85 | if isinstance(msg, dict): |
94 | 86 | for _, line in enumerate(_pretty_dict(msg).split("\n")): |
95 | | - Logger().get_logger().debug(line, *args, **kwargs, stacklevel=2) |
| 87 | + Logger().get_logger().debug(line, *args, **kwargs) |
96 | 88 | else: |
97 | | - Logger().get_logger().debug(msg, *args, **kwargs, stacklevel=2) |
| 89 | + Logger().get_logger().debug(msg, *args, **kwargs) |
98 | 90 |
|
99 | 91 |
|
100 | 92 | def error(msg, *args, **kwargs): |
101 | 93 | """Output log with the error level.""" |
102 | 94 | if isinstance(msg, dict): |
103 | 95 | for _, line in enumerate(_pretty_dict(msg).split("\n")): |
104 | | - Logger().get_logger().error(line, *args, **kwargs, stacklevel=2) |
| 96 | + Logger().get_logger().error(line, *args, **kwargs) |
105 | 97 | else: |
106 | | - Logger().get_logger().error(msg, *args, **kwargs, stacklevel=2) |
| 98 | + Logger().get_logger().error(msg, *args, **kwargs) |
107 | 99 |
|
108 | 100 |
|
109 | 101 | def fatal(msg, *args, **kwargs): |
110 | 102 | """Output log with the fatal level.""" |
111 | 103 | if isinstance(msg, dict): |
112 | 104 | for _, line in enumerate(_pretty_dict(msg).split("\n")): |
113 | | - Logger().get_logger().fatal(line, *args, **kwargs, stacklevel=2) |
| 105 | + Logger().get_logger().fatal(line, *args, **kwargs) |
114 | 106 | else: |
115 | | - Logger().get_logger().fatal(msg, *args, **kwargs, stacklevel=2) |
| 107 | + Logger().get_logger().fatal(msg, *args, **kwargs) |
116 | 108 |
|
117 | 109 |
|
118 | 110 | def info(msg, *args, **kwargs): |
119 | 111 | """Output log with the info level.""" |
120 | 112 | if isinstance(msg, dict): |
121 | 113 | for _, line in enumerate(_pretty_dict(msg).split("\n")): |
122 | | - Logger().get_logger().info(line, *args, **kwargs, stacklevel=2) |
| 114 | + Logger().get_logger().info(line, *args, **kwargs) |
123 | 115 | else: |
124 | | - Logger().get_logger().info(msg, *args, **kwargs, stacklevel=2) |
| 116 | + Logger().get_logger().info(msg, *args, **kwargs) |
125 | 117 |
|
126 | 118 |
|
127 | | -def warning(msg, *args, **kwargs): |
128 | | - """Output log with the warning level (Alias of the method warn).""" |
| 119 | +def warn(msg, *args, **kwargs): |
| 120 | + """Output log with the warning level.""" |
129 | 121 | if isinstance(msg, dict): |
130 | 122 | for _, line in enumerate(_pretty_dict(msg).split("\n")): |
131 | | - Logger().get_logger().warning(line, *args, **kwargs, stacklevel=2) |
| 123 | + Logger().get_logger().warning(line, *args, **kwargs) |
132 | 124 | else: |
133 | | - Logger().get_logger().warning(msg, *args, **kwargs, stacklevel=2) |
| 125 | + Logger().get_logger().warning(msg, *args, **kwargs) |
134 | 126 |
|
135 | 127 |
|
136 | | -level = Logger().get_logger().level |
137 | | - |
138 | | -logger = Logger().get_logger() |
| 128 | +def warning(msg, *args, **kwargs): |
| 129 | + """Output log with the warning level (Alias of the method warn).""" |
| 130 | + if isinstance(msg, dict): |
| 131 | + for _, line in enumerate(_pretty_dict(msg).split("\n")): |
| 132 | + Logger().get_logger().warning(line, *args, **kwargs) |
| 133 | + else: |
| 134 | + Logger().get_logger().warning(msg, *args, **kwargs) |
0 commit comments