Skip to content

Commit b66dcf2

Browse files
germa89akaszynski
andauthored
Removing unnecessary exception log. (#676)
* Removing innecesary exception log. * Adding a meaningful error message. And cleaning up a bit logging.py * Added more info in comments. * Grammar fixing * Update ansys/mapdl/core/mapdl.py Co-authored-by: Alex Kaszynski <[email protected]> Co-authored-by: Alex Kaszynski <[email protected]>
1 parent 8f4bf0a commit b66dcf2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ansys/mapdl/core/logging.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130

131131
## Formatting
132132

133-
STDOUT_MSG_FORMAT = '%(levelname)s - %(instance_name)s - %(module)s - %(funcName)s - %(message)s, defaults={"instance_name": None}'
133+
STDOUT_MSG_FORMAT = '%(levelname)s - %(instance_name)s - %(module)s - %(funcName)s - %(message)s'
134134

135135
FILE_MSG_FORMAT = STDOUT_MSG_FORMAT
136136

@@ -424,7 +424,6 @@ def _add_mapdl_instance_logger(self, name, mapdl_instance, level):
424424
raise ValueError("You can only input 'str' classes to this method.")
425425

426426
return instance_logger
427-
# return.level = None # TODO: To remove
428427

429428
def add_instance_logger(self, name, mapdl_instance, level=None):
430429
"""Create a logger for a MAPDL instance.

ansys/mapdl/core/mapdl.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,8 +2113,11 @@ def run(self, command, write_to_log=True, **kwargs):
21132113
response = re.sub(err_str, "", response)
21142114

21152115
if "*** ERROR ***" in response:
2116-
self._log.error(self._response)
2117-
raise MapdlRuntimeError(self._response)
2116+
# We don't need to log exception because they already included in the main logger.
2117+
# logger.error(self._response)
2118+
# However, exceptions are recorded in the global logger which do not record
2119+
# information of the instances name, hence we edit the error message.
2120+
raise MapdlRuntimeError(f"\n\nError in instance {self._name}\n\n" + self._response)
21182121
else:
21192122
warnings.warn(
21202123
"MAPDL returned non-abort errors. Please " "check the logs."

0 commit comments

Comments
 (0)