Skip to content

Commit

Permalink
Merge branch 'main' into doc/temp_fix_for_example
Browse files Browse the repository at this point in the history
  • Loading branch information
ninad-kamat authored Aug 22, 2023
2 parents 6467463 + c4b29af commit beea8dc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/ansys/meshing/prime/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ansys.meshing.prime.core.part import Part
from ansys.meshing.prime.internals.communicator import Communicator
from ansys.meshing.prime.internals.error_handling import PrimeRuntimeError
from ansys.meshing.prime.internals.logger import LOG
from ansys.meshing.prime.internals.logger import PrimeLogger


class Model(_Model):
Expand Down Expand Up @@ -369,4 +369,4 @@ def python_logger(self):
>>> model.python_logger.setLevel(logging.DEBUG)
"""
return LOG
return PrimeLogger().get_logger()
7 changes: 2 additions & 5 deletions src/ansys/meshing/prime/graphics/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def __call__(
else:
self.show(update)

def __color_by_type_callback(self): # pragma: no cover
def __color_by_type_callback(self, button_value: bool): # pragma: no cover
"""Determine the color of a type in the callback."""
vr = self._colorByTypeBt.GetRepresentation()
state = vr.GetState()
Expand All @@ -510,7 +510,7 @@ def __color_by_type_callback(self): # pragma: no cover
for disp_mesh in data["faces"]
]

def __hide_unhide_selection(self): # pragma: no cover
def __hide_unhide_selection(self, button_value: bool): # pragma: no cover
"""Hide or unhide the clicked component."""
sel_disp_mesh = self._picker.selections
if len(sel_disp_mesh) > 0:
Expand Down Expand Up @@ -601,7 +601,6 @@ def show(self, update=False):
if self._sphinx_build == False:
self._colorByTypeBt = self._plotter.add_checkbox_button_widget(
self.__color_by_type_callback,
value=int(self._color_by_type) is ColorByType.ZONELET,
position=(10, 700),
size=30,
border_size=3,
Expand Down Expand Up @@ -683,7 +682,6 @@ def __draw_parts(self, parts: List = [], update: bool = False, spline: bool = Fa
if self._sphinx_build == False:
self._colorByTypeBt = self._plotter.add_checkbox_button_widget(
self.__color_by_type_callback,
value=self._color_by_type is ColorByType.ZONELET,
position=(10, 700),
size=30,
border_size=3,
Expand Down Expand Up @@ -751,7 +749,6 @@ def __draw_scope_parts(self, update=False, scope: prime.ScopeDefinition = None):
if self._sphinx_build == False:
self._colorByTypeBt = self._plotter.add_checkbox_button_widget(
self.__color_by_type_callback,
value=self._color_by_type is ColorByType.ZONELET,
position=(10, 700),
size=30,
border_size=3,
Expand Down
17 changes: 12 additions & 5 deletions src/ansys/meshing/prime/internals/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class PrimeLogger(object, metaclass=SingletonType):

_logger = None

def __init__(self, logger_name: str = "PyPrimeMesh"):
def __init__(self, level: int = logging.ERROR, logger_name: str = "PyPrimeMesh"):
"""Logger initializer."""
self._logger = logging.getLogger(logger_name)
self._logger.setLevel(logging.DEBUG)
self._logger.setLevel(level)
self._formatter = logging.Formatter(
'%(asctime)s \t [%(levelname)s | %(filename)s:%(lineno)s] > %(message)s'
)
Expand All @@ -47,6 +47,16 @@ def get_logger(self):
"""
return self._logger

def set_level(self, level: int):
"""Set logger output level.
Parameters
----------
level : int
Level of the logger.
"""
self._logger.setLevel(level=level)

def enable_output(self, stream=None):
"""Enable logger output to given stream.
Expand Down Expand Up @@ -76,6 +86,3 @@ def add_file_handler(self, logs_dir: str = "./.log"):
file_handler = logging.FileHandler(logs_dir + "/log_" + now.strftime("%Y-%m-%d") + ".log")
file_handler.setFormatter(self._formatter)
self._logger.addHandler(file_handler)


LOG = PrimeLogger().get_logger()

0 comments on commit beea8dc

Please sign in to comment.