Merge pull request 'included stream logger. switched from default file logger to stream' (#21) from logging into main
Reviewed-on: https://nextgenerations-cities.encs.concordia.ca/gitea/CERC/hub/pulls/21
This commit is contained in:
commit
d8100cb5f9
|
@ -1,7 +1,19 @@
|
||||||
import logging as logger
|
import logging as logger
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def get_logger(file_logger=False):
|
||||||
|
"""
|
||||||
|
Returns a logging object
|
||||||
|
:param file_logger: a boolean to indicate the kind of logging
|
||||||
|
object to return, true (default) means a file logger is required
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
log_format = "%(asctime)s:%(levelname)s:{%(pathname)s:%(funcName)s:%(lineno)d} - %(message)s"
|
||||||
|
if file_logger:
|
||||||
log_dir = (Path(__file__).parent.parent / 'logs').resolve()
|
log_dir = (Path(__file__).parent.parent / 'logs').resolve()
|
||||||
log_file = (log_dir / 'hub.log').resolve()
|
log_file = (log_dir / 'hub.log').resolve()
|
||||||
try:
|
try:
|
||||||
|
@ -10,7 +22,12 @@ try:
|
||||||
os.mkdir(log_dir)
|
os.mkdir(log_dir)
|
||||||
with open(log_file, 'x'):
|
with open(log_file, 'x'):
|
||||||
pass
|
pass
|
||||||
logger.basicConfig(filename=log_file, format="%(asctime)s:%(levelname)s:{%(pathname)s:%(funcName)s:%(lineno)d} "
|
logger.basicConfig(filename=log_file, format=log_format, level=logger.DEBUG)
|
||||||
"- %(message)s", level=logger.DEBUG)
|
return logger
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
print(f'I/O exception: {err}')
|
print(f'I/O exception: {err}')
|
||||||
|
else:
|
||||||
|
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
|
||||||
|
logging.getLogger().setLevel(logging.DEBUG)
|
||||||
|
return logger.getLogger()
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
import datetime
|
import datetime
|
||||||
import math
|
import math
|
||||||
import sys
|
import sys
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
|
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
|
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
|
||||||
|
@ -17,6 +17,8 @@ from hub.helpers.dictionaries import Dictionaries
|
||||||
from hub.imports.construction.helpers.construction_helper import ConstructionHelper
|
from hub.imports.construction.helpers.construction_helper import ConstructionHelper
|
||||||
from hub.imports.construction.helpers.storeys_generation import StoreysGeneration
|
from hub.imports.construction.helpers.storeys_generation import StoreysGeneration
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class NrcanPhysicsParameters:
|
class NrcanPhysicsParameters:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -7,7 +7,7 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
|
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
|
||||||
from hub.city_model_structure.building_demand.layer import Layer
|
from hub.city_model_structure.building_demand.layer import Layer
|
||||||
from hub.city_model_structure.building_demand.material import Material
|
from hub.city_model_structure.building_demand.material import Material
|
||||||
|
@ -15,6 +15,8 @@ from hub.helpers.dictionaries import Dictionaries
|
||||||
from hub.imports.construction.helpers.construction_helper import ConstructionHelper
|
from hub.imports.construction.helpers.construction_helper import ConstructionHelper
|
||||||
from hub.imports.construction.helpers.storeys_generation import StoreysGeneration
|
from hub.imports.construction.helpers.storeys_generation import StoreysGeneration
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class NrelPhysicsParameters:
|
class NrelPhysicsParameters:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -7,11 +7,13 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
from hub.helpers.utils import validate_import_export_type
|
from hub.helpers.utils import validate_import_export_type
|
||||||
from hub.imports.construction.nrel_physics_parameters import NrelPhysicsParameters
|
from hub.imports.construction.nrel_physics_parameters import NrelPhysicsParameters
|
||||||
from hub.imports.construction.nrcan_physics_parameters import NrcanPhysicsParameters
|
from hub.imports.construction.nrcan_physics_parameters import NrcanPhysicsParameters
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class ConstructionFactory:
|
class ConstructionFactory:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -9,7 +9,9 @@ from pathlib import Path
|
||||||
from hub.imports.energy_systems.air_source_hp_parameters import AirSourceHeatPumpParameters
|
from hub.imports.energy_systems.air_source_hp_parameters import AirSourceHeatPumpParameters
|
||||||
from hub.imports.energy_systems.water_to_water_hp_parameters import WaterToWaterHPParameters
|
from hub.imports.energy_systems.water_to_water_hp_parameters import WaterToWaterHPParameters
|
||||||
from hub.helpers.utils import validate_import_export_type
|
from hub.helpers.utils import validate_import_export_type
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class EnergySystemsFactory:
|
class EnergySystemsFactory:
|
||||||
|
|
|
@ -13,7 +13,9 @@ from hub.imports.geometry.rhino import Rhino
|
||||||
from hub.imports.geometry.gpandas import GPandas
|
from hub.imports.geometry.gpandas import GPandas
|
||||||
from hub.imports.geometry.geojson import Geojson
|
from hub.imports.geometry.geojson import Geojson
|
||||||
from hub.helpers.utils import validate_import_export_type
|
from hub.helpers.utils import validate_import_export_type
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class GeometryFactory:
|
class GeometryFactory:
|
||||||
|
|
|
@ -11,7 +11,9 @@ from hub.imports.life_cycle_assessment.lca_vehicle import LcaVehicle
|
||||||
from hub.imports.life_cycle_assessment.lca_machine import LcaMachine
|
from hub.imports.life_cycle_assessment.lca_machine import LcaMachine
|
||||||
from hub.imports.life_cycle_assessment.lca_material import LcaMaterial
|
from hub.imports.life_cycle_assessment.lca_material import LcaMaterial
|
||||||
from hub.helpers.utils import validate_import_export_type
|
from hub.helpers.utils import validate_import_export_type
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class LifeCycleAssessment:
|
class LifeCycleAssessment:
|
||||||
|
|
|
@ -8,11 +8,13 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from hub.helpers.utils import validate_import_export_type
|
from hub.helpers.utils import validate_import_export_type
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
from hub.imports.results.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
|
from hub.imports.results.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
|
||||||
from hub.imports.results.insel_monthly_energry_balance import InselMonthlyEnergyBalance
|
from hub.imports.results.insel_monthly_energry_balance import InselMonthlyEnergyBalance
|
||||||
from hub.imports.results.insel_heatpump_energy_demand import InselHeatPumpEnergyDemand
|
from hub.imports.results.insel_heatpump_energy_demand import InselHeatPumpEnergyDemand
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class ResultFactory:
|
class ResultFactory:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -6,9 +6,11 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||||
Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
"""
|
"""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
from hub.helpers.utils import validate_import_export_type
|
from hub.helpers.utils import validate_import_export_type
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class SensorsFactory:
|
class SensorsFactory:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -8,7 +8,7 @@ import copy
|
||||||
import sys
|
import sys
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
from hub.helpers.dictionaries import Dictionaries
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
from hub.city_model_structure.building_demand.usage import Usage
|
from hub.city_model_structure.building_demand.usage import Usage
|
||||||
|
@ -21,6 +21,8 @@ from hub.city_model_structure.attributes.schedule import Schedule
|
||||||
from hub.city_model_structure.building_demand.internal_gain import InternalGain
|
from hub.city_model_structure.building_demand.internal_gain import InternalGain
|
||||||
from hub.catalog_factories.usage_catalog_factory import UsageCatalogFactory
|
from hub.catalog_factories.usage_catalog_factory import UsageCatalogFactory
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class ComnetUsageParameters:
|
class ComnetUsageParameters:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -7,7 +7,7 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
import hub.helpers.constants as cte
|
import hub.helpers.constants as cte
|
||||||
from hub.helpers.dictionaries import Dictionaries
|
from hub.helpers.dictionaries import Dictionaries
|
||||||
from hub.city_model_structure.building_demand.usage import Usage
|
from hub.city_model_structure.building_demand.usage import Usage
|
||||||
|
@ -18,6 +18,8 @@ from hub.city_model_structure.building_demand.thermal_control import ThermalCont
|
||||||
from hub.city_model_structure.building_demand.domestic_hot_water import DomesticHotWater
|
from hub.city_model_structure.building_demand.domestic_hot_water import DomesticHotWater
|
||||||
from hub.catalog_factories.usage_catalog_factory import UsageCatalogFactory
|
from hub.catalog_factories.usage_catalog_factory import UsageCatalogFactory
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class NrcanUsageParameters:
|
class NrcanUsageParameters:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -9,9 +9,11 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from hub.imports.usage.comnet_usage_parameters import ComnetUsageParameters
|
from hub.imports.usage.comnet_usage_parameters import ComnetUsageParameters
|
||||||
from hub.imports.usage.nrcan_usage_parameters import NrcanUsageParameters
|
from hub.imports.usage.nrcan_usage_parameters import NrcanUsageParameters
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
from hub.helpers.utils import validate_import_export_type
|
from hub.helpers.utils import validate_import_export_type
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class UsageFactory:
|
class UsageFactory:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -7,9 +7,11 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from hub.imports.weather.xls_weather_parameters import XlsWeatherParameters
|
from hub.imports.weather.xls_weather_parameters import XlsWeatherParameters
|
||||||
from hub.imports.weather.epw_weather_parameters import EpwWeatherParameters
|
from hub.imports.weather.epw_weather_parameters import EpwWeatherParameters
|
||||||
from hub.hub_logger import logger
|
from hub.hub_logger import get_logger
|
||||||
from hub.helpers.utils import validate_import_export_type
|
from hub.helpers.utils import validate_import_export_type
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class WeatherFactory:
|
class WeatherFactory:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user