Skip to content

Commit

Permalink
fixes for make_examples run
Browse files Browse the repository at this point in the history
  • Loading branch information
MyPyDavid committed Feb 17, 2022
1 parent 969b662 commit 7131f8e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ lmfit >= 1.0.0
matplotlib >= 3.1.2
numpy >= 1.19.2
openpyxl >= 3.0.1

attr
22 changes: 20 additions & 2 deletions src/raman_fitting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


from raman_fitting.config import filepath_settings
from raman_fitting.config import logging_config

# VERSION_PATH = config.PACKAGE_ROOT / 'VERSION.txt'
# with open(VERSION_PATH, 'r') as version_file:
Expand All @@ -31,14 +32,31 @@

# Configure logger for use in package
logger = logging.getLogger(__package_name__)
logger.setLevel(logging.DEBUG)

log_format = (
"[%(asctime)s] — %(name)s — %(levelname)s —" "%(funcName)s:%(lineno)d—12s %(message)s")
# '[%(asctime)s] %(levelname)-8s %(name)-12s %(message)s')

# Define basic configuration
logging.basicConfig(
# Define logging level
level=logging.DEBUG,
# Define the format of log messages
format=log_format,
# Provide the filename to store the log messages
filename=('debug.log'),
)

formatter = logging.Formatter(log_format)
# logger.setLevel(logging.DEBUG)
# from raman_fitting.config import logging_config
# logger.addHandler(logging_config.get_console_handler())
logger.propagate = False
# logger.propagate = False

# create console handler
ch = logging.StreamHandler(stream=sys.stdout)
ch.setLevel(logging.INFO)
ch.setFormatter(formatter)

# add the handlers to the logger
logger.addHandler(ch)
Expand Down
1 change: 1 addition & 0 deletions src/raman_fitting/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import logging_config
16 changes: 16 additions & 0 deletions src/raman_fitting/config/logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
)



log_format = (
"[%(asctime)s] — %(name)s — %(levelname)s —" "%(funcName)s:%(lineno)d—12s %(message)s")
# '[%(asctime)s] %(levelname)-8s %(name)-12s %(message)s')

# Define basic configuration
logging.basicConfig(
# Define logging level
level=logging.DEBUG,
# Define the format of log messages
format=log_format,
# Provide the filename to store the log messages
filename=('debug.log'),
)


def get_console_handler():
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setFormatter(FORMATTER)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" Default peaks used for 1st order deconvolution"""
import attr

if __name__ == "__main__":
from raman_fitting.deconvolution_models.default_peaks.base_peak import BasePeak
Expand Down
4 changes: 2 additions & 2 deletions src/raman_fitting/exporting/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def __init__(self, arg, raw_out=True, plot=True, model_names_prefix=["1st", "2nd
self.delegator(arg)
except ExporterError:
logger.warning(
"f{self.__class__.__qualname__} failed export from {type(arg)}"
f"{self.__class__.__qualname__} failed export from {type(arg)}"
)
except Exception as e:
logger.error(
"f{self.__class__.__qualname__} failed export with unexpected error {e}"
f"{self.__class__.__qualname__} failed export with unexpected error {e}"
)

# Exporting and Plotting
Expand Down

0 comments on commit 7131f8e

Please sign in to comment.