Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid com logging if not in debug mode #3665

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions doc/changelog.d/3665.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: avoid com logging if not in debug mode
4 changes: 3 additions & 1 deletion src/ansys/mapdl/core/mapdl_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,9 @@ def __init__(self, parent):

def __enter__(self):
self._parent()._log.debug("Entering in non-interactive mode")
self._parent().com("Entering in non_interactive mode")
if self._parent().logger.logger.level <= 10:
germa89 marked this conversation as resolved.
Show resolved Hide resolved
germa89 marked this conversation as resolved.
Show resolved Hide resolved
# only commenting if on debug mode
self._parent().com("Entering in non_interactive mode")
self._parent()._store_commands = True

def __exit__(self, *args):
Expand Down
16 changes: 16 additions & 0 deletions tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2592,3 +2592,19 @@ def test_max_cmd_len_mapdlgrpc(mapdl):
):
cmd = "a" * 640
mapdl._run(cmd)


def test_comment_on_debug_mode(mapdl, cleared):
loglevel = mapdl.logger.logger.level

mapdl.logger.logger.level = 40
germa89 marked this conversation as resolved.
Show resolved Hide resolved
with patch("ansys.mapdl.core.Mapdl.com") as mockcom:
mapdl.parameters["asdf"] = [1, 2, 3]
mockcom.assert_not_called()

mapdl.logger.logger.level = 10
with patch("ansys.mapdl.core.Mapdl.com") as mockcom:
mapdl.parameters["asdf"] = [1, 2, 3]
mockcom.assert_called_once_with("Entering in non_interactive mode")

mapdl.logger.logger.level = loglevel
Loading