diff --git a/src/analysis/compare_impacts.py b/src/analysis/compare_impacts.py index fdae771..9894365 100644 --- a/src/analysis/compare_impacts.py +++ b/src/analysis/compare_impacts.py @@ -6,7 +6,7 @@ import os import pandas as pd -from utils import setup_logging +from logs import setup_logging logger = setup_logging() diff --git a/src/analysis/forecast_twl.py b/src/analysis/forecast_twl.py index 7bab74b..0b2aea1 100644 --- a/src/analysis/forecast_twl.py +++ b/src/analysis/forecast_twl.py @@ -8,7 +8,7 @@ import pandas as pd from scipy import stats from analysis import runup_models -from utils import setup_logging +from logs import setup_logging logger = setup_logging() diff --git a/src/analysis/forecasted_storm_impacts.py b/src/analysis/forecasted_storm_impacts.py index 0a04ea1..ca4de5e 100644 --- a/src/analysis/forecasted_storm_impacts.py +++ b/src/analysis/forecasted_storm_impacts.py @@ -5,7 +5,7 @@ Estimates the forecasted storm impacts based on the forecasted water level and d import click import pandas as pd -from utils import setup_logging +from logs import setup_logging logger = setup_logging() diff --git a/src/analysis/observed_storm_impacts.py b/src/analysis/observed_storm_impacts.py index 6c4c0e1..1046cd3 100644 --- a/src/analysis/observed_storm_impacts.py +++ b/src/analysis/observed_storm_impacts.py @@ -3,7 +3,7 @@ import numpy as np import pandas as pd from scipy.integrate import simps -from utils import setup_logging +from logs import setup_logging logger = setup_logging() diff --git a/src/data/apply_manual_overwrites.py b/src/data/apply_manual_overwrites.py index 633cc63..ddcb0c0 100644 --- a/src/data/apply_manual_overwrites.py +++ b/src/data/apply_manual_overwrites.py @@ -5,7 +5,7 @@ After generating interim data files based on raw data, we may need to overwrite import pandas as pd import numpy as np import click -from utils import setup_logging +from logs import setup_logging logger = setup_logging() diff --git a/src/data/parse_mat.py b/src/data/parse_mat.py index 5ab9729..5f4f92b 100644 --- a/src/data/parse_mat.py +++ b/src/data/parse_mat.py @@ -12,7 +12,7 @@ from mat4py import loadmat from shapely.geometry import Point from data.parse_shp import convert_coord_systems -from utils import setup_logging +from logs import setup_logging logger = setup_logging() diff --git a/src/data/parse_shp.py b/src/data/parse_shp.py index 56440fd..433a0fb 100644 --- a/src/data/parse_shp.py +++ b/src/data/parse_shp.py @@ -9,7 +9,7 @@ from shapely.geometry import LineString, Point from shapely.geometry import shape from shapely.ops import transform -from utils import setup_logging +from logs import setup_logging logger = setup_logging() diff --git a/src/logs.py b/src/logs.py new file mode 100644 index 0000000..e0dfb14 --- /dev/null +++ b/src/logs.py @@ -0,0 +1,17 @@ +import logging.config +import os + +import yaml + + +def setup_logging(path="./src/logging.yaml", default_level=logging.INFO): + """ + Setup logging configuration + """ + if os.path.exists(path): + with open(path, "rt") as f: + config = yaml.safe_load(f.read()) + logging.config.dictConfig(config) + else: + logging.basicConfig(level=default_level) + return logging.getLogger(__name__) diff --git a/src/utils.py b/src/utils.py index 0df1fc6..20fb1c1 100644 --- a/src/utils.py +++ b/src/utils.py @@ -1,4 +1,3 @@ -import logging.config import os import yaml