Skip to content

Commit e5cc214

Browse files
germa89akaszynski
andauthored
WIP - Feat/ main logger (#640)
* Added procedure for silently omitting some commands (`/NOPR` for example. * Added test cases for invalid commands and invalid silent commands. * Format fixing * Added names to pool instances. * First implementation of main logger. * Second revision. * small changes in log. * Replacing default logger with pyansys logger. * Replacing logger with pyansys logger. * adding last_logger atributte. * Fixing logger hierachy and file header format. * Replacing old logger by new one. * Replacing old logger by new one. * Fixing instance name input. * Replacing old logger. Fix. * Creating tests for log * Added log tests. * Using `__name__` instead of hardcoding the name of the loggers. * Added uncaught exception recording. * Fixing style * Adding ``file_record`` and ``console_output`` options to suppress file or console output. * Adding thread naming. * Major revamp. `getLogger` got splitted in several functions to simplify reading. Added documentation at the head of the file. * Added documentation. * Updating modules to match the new log module calling method. * New revamp of the logger classes * Updating the calls to the logger. * Implementing alex comment. We forgot about distintion between threaded and normal mapdl execution. We use now instances, which has unique name. * Updating log module calls * updating log module calls and removing arguments from logs. * Added property name and logger. Also the __getitem__ to get the name from the instance, this is later used for LoggerAdapter * Adding call to loger and name attribute. * Again, big changes. Now the format is not conditional upon having or not threads. It is all based in instances of MAPDL. * Renaming the library and retooling some parts of the code. * Updating the logging library call. * Externalized function to add handlers to logger. Fix issue with conflicting ``supress_logging`` function. * Updated modules to function with new logging module. * Added functions for logging to file or stdout Added test * Added info. * Cleaning up * Added configuration for copying handlers. * Updated LOG call. * Added loglevel to instance logger. * Fixing style * Fixing style * Fix style. * Fix style. * Grammar fix. * Removing walrus operator. * Deleting old test log. * Added review suggestions. * Added review suggestions. * Applying review comments. Removed the __getitem__ method to use 'get_mame'. * Spacing changes. * Fixing logging tests. * Spacing fixing. * Added logging documentation. * Fixed rst format. * fix py37-38 difference; fix CORBA * misc cleanup Co-authored-by: Alex Kaszynski <[email protected]>
1 parent 46f2d53 commit e5cc214

File tree

11 files changed

+994
-61
lines changed

11 files changed

+994
-61
lines changed

ansys/mapdl/core/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import appdirs
22
import os
33

4+
# Importing logging
5+
import logging
6+
from ansys.mapdl.core.logging import Logger
7+
LOG = Logger(level=logging.ERROR, to_file=False, to_stdout=True)
8+
LOG.debug('Loaded logging module as LOG')
9+
410
_LOCAL_PORTS = []
511

612
# Per contract with Sphinx-Gallery, this method must be available at top level

ansys/mapdl/core/errors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""pymapdl specific errors"""
2-
import logging
2+
3+
from ansys.mapdl.core import LOG as logger
4+
35
import threading
46
import signal
57
from functools import wraps
@@ -8,8 +10,6 @@
810

911
SIGINT_TRACKER = []
1012

11-
logger = logging.getLogger(__name__)
12-
1313

1414
LOCKFILE_MSG = """
1515
Another ANSYS job with the same job name is already running in this

ansys/mapdl/core/launcher.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module for launching MAPDL locally or connecting to a remote instance with gRPC."""
2+
23
import platform
34
from glob import glob
45
import re
@@ -36,14 +37,14 @@
3637
LOCALHOST = "127.0.0.1"
3738
MAPDL_DEFAULT_PORT = 50052
3839

39-
INTEL_MSG = """Due to incompatibilites between 'DMP', Windows and VPN connections,
40+
INTEL_MSG = """Due to incompatibilities between 'DMP', Windows and VPN connections,
4041
the flat '-mpi INTELMPI' is overwritten by '-mpi msmpi'.
4142
4243
If you still want to use 'INTEL', set:
4344
4445
launch_mapdl(..., force_intel=True, additional_switches='-mpi INTELMPI')
4546
46-
Be aware of possible errors or unexpected behaviour with this configuration.
47+
Be aware of possible errors or unexpected behavior with this configuration.
4748
"""
4849

4950

@@ -123,7 +124,7 @@ def close_all_local_instances(port_range=None):
123124
port_range = range(50000, 50200)
124125

125126
@threaded
126-
def close_mapdl(port):
127+
def close_mapdl(port, name='Closing mapdl thread.'):
127128
try:
128129
mapdl = MapdlGrpc(port=port, set_no_abort=False)
129130
mapdl.exit()

0 commit comments

Comments
 (0)