diff --git a/pymilvus/bulk_writer/buffer.py b/pymilvus/bulk_writer/buffer.py index dce2ac961..9ed3f369e 100644 --- a/pymilvus/bulk_writer/buffer.py +++ b/pymilvus/bulk_writer/buffer.py @@ -33,8 +33,7 @@ BulkFileType, ) -logger = logging.getLogger("bulk_buffer") -logger.setLevel(logging.DEBUG) +logger = logging.getLogger(__name__) class Buffer: diff --git a/pymilvus/bulk_writer/bulk_import.py b/pymilvus/bulk_writer/bulk_import.py index 1c110d230..a5893145d 100644 --- a/pymilvus/bulk_writer/bulk_import.py +++ b/pymilvus/bulk_writer/bulk_import.py @@ -18,8 +18,7 @@ from pymilvus.exceptions import MilvusException -logger = logging.getLogger("bulk_import") -logger.setLevel(logging.DEBUG) +logger = logging.getLogger(__name__) def _http_headers(api_key: str): diff --git a/pymilvus/bulk_writer/local_bulk_writer.py b/pymilvus/bulk_writer/local_bulk_writer.py index a1dc9a333..051f7d053 100644 --- a/pymilvus/bulk_writer/local_bulk_writer.py +++ b/pymilvus/bulk_writer/local_bulk_writer.py @@ -26,8 +26,7 @@ BulkFileType, ) -logger = logging.getLogger("local_bulk_writer") -logger.setLevel(logging.DEBUG) +logger = logging.getLogger(__name__) class LocalBulkWriter(BulkWriter): diff --git a/pymilvus/bulk_writer/remote_bulk_writer.py b/pymilvus/bulk_writer/remote_bulk_writer.py index dd8a1945a..eeca1fe58 100644 --- a/pymilvus/bulk_writer/remote_bulk_writer.py +++ b/pymilvus/bulk_writer/remote_bulk_writer.py @@ -30,8 +30,7 @@ ) from .local_bulk_writer import LocalBulkWriter -logger = logging.getLogger("remote_bulk_writer") -logger.setLevel(logging.DEBUG) +logger = logging.getLogger(__name__) class RemoteBulkWriter(LocalBulkWriter): diff --git a/pymilvus/milvus_client/milvus_client.py b/pymilvus/milvus_client/milvus_client.py index f4a80a307..b0d51d46f 100644 --- a/pymilvus/milvus_client/milvus_client.py +++ b/pymilvus/milvus_client/milvus_client.py @@ -27,7 +27,6 @@ from .index import IndexParams logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) class MilvusClient: diff --git a/pymilvus/settings.py b/pymilvus/settings.py index c4e745073..beaee0fa4 100644 --- a/pymilvus/settings.py +++ b/pymilvus/settings.py @@ -59,44 +59,39 @@ def format(self, record: str): return self.format_col(message_str, level_name=record.levelname) -LOG_LEVEL = "WARNING" - -LOGGING = { - "version": 1, - "disable_existing_loggers": False, - "handlers": { - "console": { - "class": "logging.StreamHandler", - "level": LOG_LEVEL, +def init_log(log_level: str): + logging_config = { + "version": 1, + "disable_existing_loggers": False, + "formatters": { + "default": { + "format": "%(asctime)s [%(levelname)s][%(funcName)s]: %(message)s (%(filename)s:%(lineno)s)", + }, + "colorful_console": { + "format": "%(asctime)s | %(levelname)s: %(message)s (%(filename)s:%(lineno)s) (%(process)s)", + "()": ColorfulFormatter, + }, }, - }, - "loggers": { - "milvus": { - "handlers": ["console"], - "level": LOG_LEVEL, + "handlers": { + "console": { + "class": "logging.StreamHandler", + "formatter": "colorful_console", + }, + "no_color_console": { + "class": "logging.StreamHandler", + "formatter": "default", + }, }, - }, -} - -if LOG_LEVEL == "DEBUG": - LOGGING["formatters"] = { - "colorful_console": { - "format": "[%(asctime)s-%(levelname)s-%(name)s]: %(message)s (%(filename)s:%(lineno)s)", - "()": ColorfulFormatter, + "loggers": { + "pymilvus": {"handlers": ["no_color_console"], "level": log_level, "propagate": False}, + "pymilvus.milvus_client": { + "handlers": ["no_color_console"], + "level": "INFO", + "propagate": False, + }, }, } - LOGGING["handlers"]["milvus_console"] = { - "class": "logging.StreamHandler", - "formatter": "colorful_console", - } - LOGGING["loggers"]["milvus"] = { - "handlers": ["milvus_console"], - "level": LOG_LEVEL, - } + logging.config.dictConfig(logging_config) -logging.config.dictConfig(LOGGING) -DEBUG_LOG_LEVEL = "debug" -INFO_LOG_LEVEL = "info" -WARN_LOG_LEVEL = "warn" -ERROR_LOG_LEVEL = "error" +init_log("WARNING")