diff --git a/butterfree/_cli/migrate.py b/butterfree/_cli/migrate.py index 207e7daf..a718832d 100644 --- a/butterfree/_cli/migrate.py +++ b/butterfree/_cli/migrate.py @@ -1,6 +1,7 @@ import datetime import importlib import inspect +import logging import os import pkgutil import sys @@ -12,7 +13,6 @@ from botocore.exceptions import ClientError from butterfree.configs import environment -from butterfree.configs.logger import __logger from butterfree.migrations.database_migration import ALLOWED_DATABASE from butterfree.pipelines import FeatureSetPipeline @@ -20,7 +20,7 @@ help="Apply the automatic migrations in a database.", no_args_is_help=True ) -logger = __logger("migrate", True) +logger = logging.getLogger(__name__) def __find_modules(path: str) -> Set[str]: diff --git a/butterfree/clients/cassandra_client.py b/butterfree/clients/cassandra_client.py index 0b300844..c4d34521 100644 --- a/butterfree/clients/cassandra_client.py +++ b/butterfree/clients/cassandra_client.py @@ -1,5 +1,6 @@ """CassandraClient entity.""" +import logging from ssl import CERT_REQUIRED, PROTOCOL_TLSv1 from typing import Dict, List, Optional, Union @@ -16,9 +17,8 @@ from typing_extensions import TypedDict from butterfree.clients import AbstractClient -from butterfree.configs.logger import __logger -logger = __logger("cassandra_client") +logger = logging.getLogger(__name__) EMPTY_STRING_HOST_ERROR = "The value of Cassandra host is empty. Please fill correctly with your endpoints" # noqa: E501 GENERIC_INVALID_HOST_ERROR = "The Cassandra host must be a valid string, a string that represents a list or list of strings" # noqa: E501 diff --git a/butterfree/configs/logger.py b/butterfree/configs/logger.py deleted file mode 100644 index 60dab67c..00000000 --- a/butterfree/configs/logger.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Logger funcion.""" - -import logging - - -def __config(json_file_logs: bool = False) -> None: - - if json_file_logs: - return logging.basicConfig( - format='{"name": "%(name)s", "timestamp": "%(asctime)-15s", ' - '"level": "%(levelname)s", "message": "%(message)s"}', - level=logging.INFO, - filename="../logging.json", - ) - return logging.basicConfig( - format="%(name)s:%(asctime)-15s:%(levelname)s:< %(message)s >", - level=logging.INFO, - ) - - -def __logger(name: str, file_logs: bool = False) -> logging.Logger: - - __config(file_logs) - return logging.getLogger(name) diff --git a/butterfree/load/writers/delta_writer.py b/butterfree/load/writers/delta_writer.py index 933f1adb..45ce1c0c 100644 --- a/butterfree/load/writers/delta_writer.py +++ b/butterfree/load/writers/delta_writer.py @@ -1,10 +1,11 @@ +import logging + from delta.tables import DeltaTable from pyspark.sql.dataframe import DataFrame from butterfree.clients import SparkClient -from butterfree.configs.logger import __logger -logger = __logger("delta_writer", True) +logger = logging.getLogger(__name__) class DeltaWriter: diff --git a/butterfree/migrations/database_migration/database_migration.py b/butterfree/migrations/database_migration/database_migration.py index 351a4724..aa07fb35 100644 --- a/butterfree/migrations/database_migration/database_migration.py +++ b/butterfree/migrations/database_migration/database_migration.py @@ -1,16 +1,16 @@ """Migration entity.""" +import logging from abc import ABC, abstractmethod from dataclasses import dataclass from enum import Enum, auto from typing import Any, Dict, List, Optional, Set from butterfree.clients import AbstractClient -from butterfree.configs.logger import __logger from butterfree.load.writers.writer import Writer from butterfree.transform import FeatureSet -logger = __logger("database_migrate", True) +logger = logging.getLogger(__name__) @dataclass