pyedb 0.2.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.
Potentially problematic release.
This version of pyedb might be problematic. Click here for more details.
- pyedb/__init__.py +17 -0
- pyedb/dotnet/__init__.py +0 -0
- pyedb/dotnet/application/Variables.py +2261 -0
- pyedb/dotnet/application/__init__.py +0 -0
- pyedb/dotnet/clr_module.py +103 -0
- pyedb/dotnet/edb.py +4237 -0
- pyedb/dotnet/edb_core/__init__.py +1 -0
- pyedb/dotnet/edb_core/cell/__init__.py +0 -0
- pyedb/dotnet/edb_core/cell/hierarchy/__init__.py +0 -0
- pyedb/dotnet/edb_core/cell/hierarchy/model.py +66 -0
- pyedb/dotnet/edb_core/components.py +2669 -0
- pyedb/dotnet/edb_core/configuration.py +423 -0
- pyedb/dotnet/edb_core/definition/__init__.py +0 -0
- pyedb/dotnet/edb_core/definition/component_def.py +166 -0
- pyedb/dotnet/edb_core/definition/component_model.py +30 -0
- pyedb/dotnet/edb_core/definition/definition_obj.py +18 -0
- pyedb/dotnet/edb_core/definition/definitions.py +12 -0
- pyedb/dotnet/edb_core/dotnet/__init__.py +0 -0
- pyedb/dotnet/edb_core/dotnet/database.py +1218 -0
- pyedb/dotnet/edb_core/dotnet/layout.py +238 -0
- pyedb/dotnet/edb_core/dotnet/primitive.py +1517 -0
- pyedb/dotnet/edb_core/edb_data/__init__.py +0 -0
- pyedb/dotnet/edb_core/edb_data/components_data.py +938 -0
- pyedb/dotnet/edb_core/edb_data/connectable.py +113 -0
- pyedb/dotnet/edb_core/edb_data/control_file.py +1268 -0
- pyedb/dotnet/edb_core/edb_data/design_options.py +35 -0
- pyedb/dotnet/edb_core/edb_data/edbvalue.py +45 -0
- pyedb/dotnet/edb_core/edb_data/hfss_extent_info.py +330 -0
- pyedb/dotnet/edb_core/edb_data/hfss_simulation_setup_data.py +1607 -0
- pyedb/dotnet/edb_core/edb_data/layer_data.py +576 -0
- pyedb/dotnet/edb_core/edb_data/nets_data.py +281 -0
- pyedb/dotnet/edb_core/edb_data/obj_base.py +19 -0
- pyedb/dotnet/edb_core/edb_data/padstacks_data.py +2080 -0
- pyedb/dotnet/edb_core/edb_data/ports.py +287 -0
- pyedb/dotnet/edb_core/edb_data/primitives_data.py +1397 -0
- pyedb/dotnet/edb_core/edb_data/simulation_configuration.py +2914 -0
- pyedb/dotnet/edb_core/edb_data/simulation_setup.py +716 -0
- pyedb/dotnet/edb_core/edb_data/siwave_simulation_setup_data.py +1205 -0
- pyedb/dotnet/edb_core/edb_data/sources.py +514 -0
- pyedb/dotnet/edb_core/edb_data/terminals.py +632 -0
- pyedb/dotnet/edb_core/edb_data/utilities.py +148 -0
- pyedb/dotnet/edb_core/edb_data/variables.py +91 -0
- pyedb/dotnet/edb_core/general.py +181 -0
- pyedb/dotnet/edb_core/hfss.py +1646 -0
- pyedb/dotnet/edb_core/layout.py +1244 -0
- pyedb/dotnet/edb_core/layout_validation.py +272 -0
- pyedb/dotnet/edb_core/materials.py +939 -0
- pyedb/dotnet/edb_core/net_class.py +335 -0
- pyedb/dotnet/edb_core/nets.py +1215 -0
- pyedb/dotnet/edb_core/padstack.py +1389 -0
- pyedb/dotnet/edb_core/siwave.py +1427 -0
- pyedb/dotnet/edb_core/stackup.py +2703 -0
- pyedb/edb_logger.py +396 -0
- pyedb/generic/__init__.py +0 -0
- pyedb/generic/constants.py +1063 -0
- pyedb/generic/data_handlers.py +320 -0
- pyedb/generic/design_types.py +104 -0
- pyedb/generic/filesystem.py +150 -0
- pyedb/generic/general_methods.py +1535 -0
- pyedb/generic/plot.py +1840 -0
- pyedb/generic/process.py +285 -0
- pyedb/generic/settings.py +224 -0
- pyedb/ipc2581/__init__.py +0 -0
- pyedb/ipc2581/bom/__init__.py +0 -0
- pyedb/ipc2581/bom/bom.py +21 -0
- pyedb/ipc2581/bom/bom_item.py +32 -0
- pyedb/ipc2581/bom/characteristics.py +37 -0
- pyedb/ipc2581/bom/refdes.py +16 -0
- pyedb/ipc2581/content/__init__.py +0 -0
- pyedb/ipc2581/content/color.py +38 -0
- pyedb/ipc2581/content/content.py +55 -0
- pyedb/ipc2581/content/dictionary_color.py +29 -0
- pyedb/ipc2581/content/dictionary_fill.py +28 -0
- pyedb/ipc2581/content/dictionary_line.py +30 -0
- pyedb/ipc2581/content/entry_color.py +13 -0
- pyedb/ipc2581/content/entry_line.py +14 -0
- pyedb/ipc2581/content/fill.py +15 -0
- pyedb/ipc2581/content/layer_ref.py +10 -0
- pyedb/ipc2581/content/standard_geometries_dictionary.py +72 -0
- pyedb/ipc2581/ecad/__init__.py +0 -0
- pyedb/ipc2581/ecad/cad_data/__init__.py +0 -0
- pyedb/ipc2581/ecad/cad_data/assembly_drawing.py +26 -0
- pyedb/ipc2581/ecad/cad_data/cad_data.py +37 -0
- pyedb/ipc2581/ecad/cad_data/component.py +41 -0
- pyedb/ipc2581/ecad/cad_data/drill.py +30 -0
- pyedb/ipc2581/ecad/cad_data/feature.py +54 -0
- pyedb/ipc2581/ecad/cad_data/layer.py +41 -0
- pyedb/ipc2581/ecad/cad_data/layer_feature.py +151 -0
- pyedb/ipc2581/ecad/cad_data/logical_net.py +32 -0
- pyedb/ipc2581/ecad/cad_data/outline.py +25 -0
- pyedb/ipc2581/ecad/cad_data/package.py +104 -0
- pyedb/ipc2581/ecad/cad_data/padstack_def.py +38 -0
- pyedb/ipc2581/ecad/cad_data/padstack_hole_def.py +24 -0
- pyedb/ipc2581/ecad/cad_data/padstack_instance.py +62 -0
- pyedb/ipc2581/ecad/cad_data/padstack_pad_def.py +26 -0
- pyedb/ipc2581/ecad/cad_data/path.py +89 -0
- pyedb/ipc2581/ecad/cad_data/phy_net.py +80 -0
- pyedb/ipc2581/ecad/cad_data/pin.py +31 -0
- pyedb/ipc2581/ecad/cad_data/polygon.py +169 -0
- pyedb/ipc2581/ecad/cad_data/profile.py +40 -0
- pyedb/ipc2581/ecad/cad_data/stackup.py +31 -0
- pyedb/ipc2581/ecad/cad_data/stackup_group.py +42 -0
- pyedb/ipc2581/ecad/cad_data/stackup_layer.py +21 -0
- pyedb/ipc2581/ecad/cad_data/step.py +275 -0
- pyedb/ipc2581/ecad/cad_header.py +33 -0
- pyedb/ipc2581/ecad/ecad.py +19 -0
- pyedb/ipc2581/ecad/spec.py +46 -0
- pyedb/ipc2581/history_record.py +37 -0
- pyedb/ipc2581/ipc2581.py +387 -0
- pyedb/ipc2581/logistic_header.py +25 -0
- pyedb/misc/__init__.py +0 -0
- pyedb/misc/aedtlib_personalib_install.py +14 -0
- pyedb/misc/downloads.py +322 -0
- pyedb/misc/misc.py +67 -0
- pyedb/misc/pyedb.runtimeconfig.json +13 -0
- pyedb/misc/siw_feature_config/__init__.py +0 -0
- pyedb/misc/siw_feature_config/emc/__init__.py +0 -0
- pyedb/misc/siw_feature_config/emc/component_tags.py +46 -0
- pyedb/misc/siw_feature_config/emc/net_tags.py +37 -0
- pyedb/misc/siw_feature_config/emc/tag_library.py +62 -0
- pyedb/misc/siw_feature_config/emc/xml_generic.py +78 -0
- pyedb/misc/siw_feature_config/emc_rule_checker_settings.py +179 -0
- pyedb/misc/utilities.py +27 -0
- pyedb/modeler/geometry_operators.py +2082 -0
- pyedb-0.2.0.dist-info/LICENSE +21 -0
- pyedb-0.2.0.dist-info/METADATA +208 -0
- pyedb-0.2.0.dist-info/RECORD +128 -0
- pyedb-0.2.0.dist-info/WHEEL +4 -0
pyedb/edb_logger.py
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import logging
|
|
3
|
+
from logging.handlers import RotatingFileHandler
|
|
4
|
+
import os
|
|
5
|
+
import shutil
|
|
6
|
+
import sys
|
|
7
|
+
import tempfile
|
|
8
|
+
import time
|
|
9
|
+
|
|
10
|
+
from pyedb.generic.settings import settings
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Msg:
|
|
14
|
+
(INFO, WARNING, ERROR, FATAL) = range(4)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AppFilter(logging.Filter):
|
|
18
|
+
"""Specifies the destination of the logger.
|
|
19
|
+
|
|
20
|
+
AEDT exposes three different loggers, which are the global, project, and design loggers.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
destination : str, optional
|
|
25
|
+
Logger to write to. Options are ``"Global"`, ``"Project"``, and ``"Design"``.
|
|
26
|
+
The default is ``"Global"``.
|
|
27
|
+
extra : str, optional
|
|
28
|
+
Name of the design or project. The default is ``""``.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, destination="Global", extra=""):
|
|
32
|
+
self._destination = destination
|
|
33
|
+
self._extra = extra
|
|
34
|
+
|
|
35
|
+
def filter(self, record):
|
|
36
|
+
"""
|
|
37
|
+
Modify the record sent to the logger.
|
|
38
|
+
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
record : class:`logging.LogRecord`
|
|
42
|
+
Contains information related to the event being logged.
|
|
43
|
+
"""
|
|
44
|
+
record.destination = self._destination
|
|
45
|
+
|
|
46
|
+
# This will avoid the extra '::' for Global that does not have any extra info.
|
|
47
|
+
if not self._extra:
|
|
48
|
+
record.extra = self._extra
|
|
49
|
+
else:
|
|
50
|
+
record.extra = self._extra + ":"
|
|
51
|
+
return True
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class EdbLogger(object):
|
|
55
|
+
"""
|
|
56
|
+
Specifies the logger to use for EDB logger.
|
|
57
|
+
|
|
58
|
+
This class allows you to add a handler to write messages to a file and to indicate
|
|
59
|
+
whether to write messages to the standard output (stdout).
|
|
60
|
+
|
|
61
|
+
Parameters
|
|
62
|
+
----------
|
|
63
|
+
level : int, optional
|
|
64
|
+
Logging level to filter the message severity allowed in the logger.
|
|
65
|
+
The default is ``logging.DEBUG``.
|
|
66
|
+
filename : str, optional
|
|
67
|
+
Name of the file to write messages to. The default is ``None``.
|
|
68
|
+
to_stdout : bool, optional
|
|
69
|
+
Whether to write log messages to stdout. The default is ``False``.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
def __init__(self, level=logging.DEBUG, filename=None, to_stdout=False):
|
|
73
|
+
self._std_out_handler = None
|
|
74
|
+
self._files_handlers = []
|
|
75
|
+
self.level = level
|
|
76
|
+
self.filename = filename or settings.logger_file_path
|
|
77
|
+
settings.logger_file_path = self.filename
|
|
78
|
+
|
|
79
|
+
self._global = logging.getLogger("Global")
|
|
80
|
+
if not settings.enable_logger:
|
|
81
|
+
self._global.addHandler(logging.NullHandler())
|
|
82
|
+
return
|
|
83
|
+
self._global.setLevel(level)
|
|
84
|
+
self._global.addFilter(AppFilter())
|
|
85
|
+
if settings.formatter:
|
|
86
|
+
self.formatter = settings.formatter
|
|
87
|
+
else:
|
|
88
|
+
self.formatter = logging.Formatter(settings.logger_formatter, datefmt=settings.logger_datefmt)
|
|
89
|
+
global_handler = False
|
|
90
|
+
if settings.enable_global_log_file:
|
|
91
|
+
for handler in self._global.handlers:
|
|
92
|
+
if settings.global_log_file_name in str(handler):
|
|
93
|
+
global_handler = True
|
|
94
|
+
break
|
|
95
|
+
log_file = os.path.join(tempfile.gettempdir(), settings.global_log_file_name)
|
|
96
|
+
my_handler = RotatingFileHandler(
|
|
97
|
+
log_file,
|
|
98
|
+
mode="a",
|
|
99
|
+
maxBytes=float(settings.global_log_file_size) * 1024 * 1024,
|
|
100
|
+
backupCount=2,
|
|
101
|
+
encoding="utf-8",
|
|
102
|
+
delay=0,
|
|
103
|
+
)
|
|
104
|
+
my_handler.setFormatter(self.formatter)
|
|
105
|
+
my_handler.setLevel(self.level)
|
|
106
|
+
if not global_handler and settings.global_log_file_name:
|
|
107
|
+
self._global.addHandler(my_handler)
|
|
108
|
+
self._files_handlers.append(my_handler)
|
|
109
|
+
if self.filename and os.path.exists(self.filename):
|
|
110
|
+
shutil.rmtree(self.filename, ignore_errors=True)
|
|
111
|
+
if self.filename and settings.enable_local_log_file:
|
|
112
|
+
self.add_file_logger(self.filename)
|
|
113
|
+
|
|
114
|
+
if to_stdout:
|
|
115
|
+
settings.enable_screen_logs = True
|
|
116
|
+
self._std_out_handler = logging.StreamHandler(sys.stdout)
|
|
117
|
+
self._std_out_handler.setLevel(level)
|
|
118
|
+
_logger_stdout_formatter = logging.Formatter("PyEDB %(levelname)s: %(message)s")
|
|
119
|
+
|
|
120
|
+
self._std_out_handler.setFormatter(_logger_stdout_formatter)
|
|
121
|
+
self._global.addHandler(self._std_out_handler)
|
|
122
|
+
self._timer = time.time()
|
|
123
|
+
|
|
124
|
+
def add_file_logger(self, filename):
|
|
125
|
+
"""Add a new file to the logger handlers list."""
|
|
126
|
+
_file_handler = logging.FileHandler(filename)
|
|
127
|
+
_file_handler.setFormatter(self.formatter)
|
|
128
|
+
self.info("New logger file {} added to handlers.".format(filename))
|
|
129
|
+
self._files_handlers.append(_file_handler)
|
|
130
|
+
return True
|
|
131
|
+
|
|
132
|
+
def remove_file_logger(self, project_name):
|
|
133
|
+
"""Remove a file from the logger handlers list."""
|
|
134
|
+
handlers = [i for i in self._global.handlers]
|
|
135
|
+
for handler in self._files_handlers:
|
|
136
|
+
if "pyedb_{}.log".format(project_name) in str(handler):
|
|
137
|
+
handler.close()
|
|
138
|
+
if handler in handlers:
|
|
139
|
+
self._global.removeHandler(handler)
|
|
140
|
+
self.info("logger file pyedb_{}.log removed from handlers.".format(project_name))
|
|
141
|
+
|
|
142
|
+
def remove_all_file_loggers(self):
|
|
143
|
+
"""Remove all file loggers."""
|
|
144
|
+
handlers = [i for i in self._global.handlers]
|
|
145
|
+
for handler in handlers:
|
|
146
|
+
if "pyedb_" in str(handler):
|
|
147
|
+
handler.close()
|
|
148
|
+
self._global.removeHandler(handler)
|
|
149
|
+
|
|
150
|
+
@property
|
|
151
|
+
def _log_on_file(self):
|
|
152
|
+
return settings.enable_file_logs
|
|
153
|
+
|
|
154
|
+
@_log_on_file.setter
|
|
155
|
+
def _log_on_file(self, val):
|
|
156
|
+
settings.enable_file_logs = val
|
|
157
|
+
|
|
158
|
+
@property
|
|
159
|
+
def logger(self):
|
|
160
|
+
"""EDB logger object."""
|
|
161
|
+
if self._log_on_file:
|
|
162
|
+
return logging.getLogger("Global")
|
|
163
|
+
else:
|
|
164
|
+
return None # pragma: no cover
|
|
165
|
+
|
|
166
|
+
def reset_timer(self, time_val=None):
|
|
167
|
+
""" "Reset actual timer to actual time or specified time.
|
|
168
|
+
|
|
169
|
+
Parameters
|
|
170
|
+
----------
|
|
171
|
+
time_val : float, optional
|
|
172
|
+
Value time to apply.
|
|
173
|
+
|
|
174
|
+
Returns
|
|
175
|
+
-------
|
|
176
|
+
|
|
177
|
+
"""
|
|
178
|
+
if time_val:
|
|
179
|
+
self._timer = time_val
|
|
180
|
+
else:
|
|
181
|
+
self._timer = time.time()
|
|
182
|
+
return self._timer
|
|
183
|
+
|
|
184
|
+
def add_error_message(self, message_text):
|
|
185
|
+
"""
|
|
186
|
+
Add a type 2 "Error" message to the message manager tree.
|
|
187
|
+
|
|
188
|
+
Also add an error message to the logger if the handler is present.
|
|
189
|
+
|
|
190
|
+
Parameters
|
|
191
|
+
----------
|
|
192
|
+
message_text : str
|
|
193
|
+
Text to display as the error message.
|
|
194
|
+
|
|
195
|
+
"""
|
|
196
|
+
self.add_message(2, message_text)
|
|
197
|
+
|
|
198
|
+
def add_warning_message(self, message_text):
|
|
199
|
+
"""
|
|
200
|
+
Add a type 1 "Warning" message to the message manager tree.
|
|
201
|
+
|
|
202
|
+
Also add a warning message to the logger if the handler is present.
|
|
203
|
+
|
|
204
|
+
Parameters
|
|
205
|
+
----------
|
|
206
|
+
message_text : str
|
|
207
|
+
Text to display as the warning message.
|
|
208
|
+
|
|
209
|
+
Examples
|
|
210
|
+
--------
|
|
211
|
+
Add a warning message to the EDB message manager.
|
|
212
|
+
|
|
213
|
+
>>> edb.logger.warning("Global warning message")
|
|
214
|
+
|
|
215
|
+
"""
|
|
216
|
+
self.add_message(1, message_text)
|
|
217
|
+
|
|
218
|
+
def add_info_message(self, message_text):
|
|
219
|
+
"""Add a type 0 "Info" message to the active design level of the message manager tree.
|
|
220
|
+
|
|
221
|
+
Also add an info message to the logger if the handler is present.
|
|
222
|
+
|
|
223
|
+
Parameters
|
|
224
|
+
----------
|
|
225
|
+
message_text : str
|
|
226
|
+
Text to display as the info message.
|
|
227
|
+
|
|
228
|
+
Examples
|
|
229
|
+
--------
|
|
230
|
+
Add an info message at the global level.
|
|
231
|
+
|
|
232
|
+
>>> edb.logger.info("Global warning message")
|
|
233
|
+
|
|
234
|
+
"""
|
|
235
|
+
self.add_message(0, message_text)
|
|
236
|
+
|
|
237
|
+
def add_debug_message(self, message_text):
|
|
238
|
+
"""
|
|
239
|
+
Parameterized message to the message manager.
|
|
240
|
+
|
|
241
|
+
Parameters
|
|
242
|
+
----------
|
|
243
|
+
message_text : str
|
|
244
|
+
Text to display as the message.
|
|
245
|
+
"""
|
|
246
|
+
|
|
247
|
+
return self.add_message(3, message_text)
|
|
248
|
+
|
|
249
|
+
def add_message(self, message_type, message_text):
|
|
250
|
+
"""Add a message to the message manager.
|
|
251
|
+
|
|
252
|
+
Parameters
|
|
253
|
+
----------
|
|
254
|
+
message_type : int
|
|
255
|
+
Type of the message. Options are:
|
|
256
|
+
* ``0`` : Info
|
|
257
|
+
* ``1`` : Warning
|
|
258
|
+
* ``2`` : Error
|
|
259
|
+
* ``3`` : Debug
|
|
260
|
+
message_text : str
|
|
261
|
+
Text to display as the message.
|
|
262
|
+
"""
|
|
263
|
+
self._log_on_handler(message_type, message_text)
|
|
264
|
+
|
|
265
|
+
def _log_on_handler(self, message_type, message_text, *args, **kwargs):
|
|
266
|
+
if not (self._log_on_file or self._log_on_screen) or not self._global:
|
|
267
|
+
return
|
|
268
|
+
if len(message_text) > 250:
|
|
269
|
+
message_text = message_text[:250] + "..."
|
|
270
|
+
if message_type == 0:
|
|
271
|
+
self._global.info(message_text, *args, **kwargs)
|
|
272
|
+
elif message_type == 1:
|
|
273
|
+
self._global.warning(message_text, *args, **kwargs)
|
|
274
|
+
elif message_type == 2:
|
|
275
|
+
self._global.error(message_text, *args, **kwargs)
|
|
276
|
+
elif message_type == 3:
|
|
277
|
+
self._global.debug(message_text, *args, **kwargs)
|
|
278
|
+
|
|
279
|
+
def disable_stdout_log(self):
|
|
280
|
+
"""Disable printing log messages to stdout."""
|
|
281
|
+
self._log_on_screen = False
|
|
282
|
+
self._global.removeHandler(self._std_out_handler)
|
|
283
|
+
self.info("StdOut is disabled")
|
|
284
|
+
|
|
285
|
+
def enable_stdout_log(self):
|
|
286
|
+
"""Enable printing log messages to stdout."""
|
|
287
|
+
self._log_on_screen = True
|
|
288
|
+
if not self._std_out_handler:
|
|
289
|
+
self._std_out_handler = logging.StreamHandler(sys.stdout)
|
|
290
|
+
self._std_out_handler.setLevel(self.level)
|
|
291
|
+
_logger_stdout_formatter = logging.Formatter("pyedb %(levelname)s: %(message)s")
|
|
292
|
+
|
|
293
|
+
self._std_out_handler.setFormatter(_logger_stdout_formatter)
|
|
294
|
+
self._global.addHandler(self._std_out_handler)
|
|
295
|
+
self._global.addHandler(self._std_out_handler)
|
|
296
|
+
self.info("StdOut is enabled")
|
|
297
|
+
|
|
298
|
+
def disable_log_on_file(self):
|
|
299
|
+
"""Disable writing log messages to an output file."""
|
|
300
|
+
self._log_on_file = False
|
|
301
|
+
for _file_handler in self._files_handlers:
|
|
302
|
+
_file_handler.close()
|
|
303
|
+
self._global.removeHandler(_file_handler)
|
|
304
|
+
self.info("Log on file is disabled")
|
|
305
|
+
|
|
306
|
+
def enable_log_on_file(self):
|
|
307
|
+
"""Enable writing log messages to an output file."""
|
|
308
|
+
self._log_on_file = True
|
|
309
|
+
for _file_handler in self._files_handlers:
|
|
310
|
+
self._global.addHandler(_file_handler)
|
|
311
|
+
self.info("Log on file is enabled")
|
|
312
|
+
|
|
313
|
+
def info(self, msg, *args, **kwargs):
|
|
314
|
+
"""Write an info message to the global logger."""
|
|
315
|
+
if not settings.enable_logger:
|
|
316
|
+
return
|
|
317
|
+
if args:
|
|
318
|
+
try:
|
|
319
|
+
msg1 = msg % tuple(str(i) for i in args)
|
|
320
|
+
except TypeError:
|
|
321
|
+
msg1 = msg
|
|
322
|
+
else:
|
|
323
|
+
msg1 = msg
|
|
324
|
+
return self._log_on_handler(0, msg, *args, **kwargs)
|
|
325
|
+
|
|
326
|
+
def info_timer(self, msg, start_time=None, *args, **kwargs):
|
|
327
|
+
"""Write an info message to the global logger with elapsed time.
|
|
328
|
+
Message will have an appendix of type Elapsed time: time."""
|
|
329
|
+
if not settings.enable_logger:
|
|
330
|
+
return
|
|
331
|
+
if not start_time:
|
|
332
|
+
start_time = self._timer
|
|
333
|
+
td = time.time() - start_time
|
|
334
|
+
m, s = divmod(td, 60)
|
|
335
|
+
h, m = divmod(m, 60)
|
|
336
|
+
d, h = divmod(h, 24)
|
|
337
|
+
if d > 0:
|
|
338
|
+
msg += " Elapsed time: {}days {}h {}m {}sec".format(round(d), round(h), round(m), round(s))
|
|
339
|
+
elif h > 0:
|
|
340
|
+
msg += " Elapsed time: {}h {}m {}sec".format(round(h), round(m), round(s))
|
|
341
|
+
else:
|
|
342
|
+
msg += " Elapsed time: {}m {}sec".format(round(m), round(s))
|
|
343
|
+
if args:
|
|
344
|
+
try:
|
|
345
|
+
msg1 = msg % tuple(str(i) for i in args)
|
|
346
|
+
except TypeError:
|
|
347
|
+
msg1 = msg
|
|
348
|
+
else:
|
|
349
|
+
msg1 = msg
|
|
350
|
+
return self._log_on_handler(0, msg, *args, **kwargs)
|
|
351
|
+
|
|
352
|
+
def warning(self, msg, *args, **kwargs):
|
|
353
|
+
"""Write a warning message to the global logger."""
|
|
354
|
+
if not settings.enable_logger:
|
|
355
|
+
return
|
|
356
|
+
if args:
|
|
357
|
+
try:
|
|
358
|
+
msg1 = msg % tuple(str(i) for i in args)
|
|
359
|
+
except TypeError:
|
|
360
|
+
msg1 = msg
|
|
361
|
+
else:
|
|
362
|
+
msg1 = msg
|
|
363
|
+
return self._log_on_handler(1, msg, *args, **kwargs)
|
|
364
|
+
|
|
365
|
+
def error(self, msg, *args, **kwargs):
|
|
366
|
+
"""Write an error message to the global logger."""
|
|
367
|
+
if args:
|
|
368
|
+
try:
|
|
369
|
+
msg1 = msg % tuple(str(i) for i in args)
|
|
370
|
+
except TypeError:
|
|
371
|
+
msg1 = msg
|
|
372
|
+
else:
|
|
373
|
+
msg1 = msg
|
|
374
|
+
return self._log_on_handler(2, msg, *args, **kwargs)
|
|
375
|
+
|
|
376
|
+
def debug(self, msg, *args, **kwargs):
|
|
377
|
+
"""Write a debug message to the global logger."""
|
|
378
|
+
if not settings.enable_debug_logger or not settings.enable_logger:
|
|
379
|
+
return
|
|
380
|
+
if args:
|
|
381
|
+
try:
|
|
382
|
+
msg1 = msg % tuple(str(i) for i in args)
|
|
383
|
+
except TypeError:
|
|
384
|
+
msg1 = msg
|
|
385
|
+
else:
|
|
386
|
+
msg1 = msg
|
|
387
|
+
return self._log_on_handler(3, msg, *args, **kwargs)
|
|
388
|
+
|
|
389
|
+
@property
|
|
390
|
+
def glb(self):
|
|
391
|
+
"""Global logger."""
|
|
392
|
+
self._global = logging.getLogger("Global")
|
|
393
|
+
return self._global
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
pyedb_logger = EdbLogger(to_stdout=settings.enable_screen_logs)
|
|
File without changes
|