From 6f61f16c3021a0819efc76608215ed93d612e257 Mon Sep 17 00:00:00 2001 From: Hu Yueh-Wei Date: Wed, 30 Oct 2024 22:32:53 +0800 Subject: [PATCH] chore: remote log.py --- .../default_async_extension_python/BUILD.gn | 2 -- .../BUILD_release.gn | 1 - .../BUILD_release.gn.tent | 1 - .../__init__.py | 3 --- .../__init__.py.tent | 3 --- .../default_async_extension_python/addon.py | 3 +-- .../addon.py.tent | 3 +-- .../default_async_extension_python/log.py | 20 ------------------- .../log.py.tent | 20 ------------------- .../default_extension_python/BUILD.gn | 2 -- .../default_extension_python/BUILD_release.gn | 1 - .../BUILD_release.gn.tent | 1 - .../default_extension_python/__init__.py | 3 --- .../default_extension_python/__init__.py.tent | 3 --- .../default_extension_python/addon.py | 3 +-- .../default_extension_python/addon.py.tent | 3 +-- .../default_extension_python/log.py | 20 ------------------- .../default_extension_python/log.py.tent | 20 ------------------- .../default_extension_python/__init__.pyx | 3 --- .../default_extension_python/addon.pyx | 3 +-- .../default_extension_python/__init__.py | 3 --- .../default_extension_python/addon.py | 3 +-- .../default_extension_python/__init__.py | 3 --- .../default_extension_python/addon.py | 3 +-- 24 files changed, 7 insertions(+), 123 deletions(-) delete mode 100644 packages/core_extensions/default_async_extension_python/log.py delete mode 100644 packages/core_extensions/default_async_extension_python/log.py.tent delete mode 100644 packages/core_extensions/default_extension_python/log.py delete mode 100644 packages/core_extensions/default_extension_python/log.py.tent diff --git a/packages/core_extensions/default_async_extension_python/BUILD.gn b/packages/core_extensions/default_async_extension_python/BUILD.gn index a762096779..daf677f519 100644 --- a/packages/core_extensions/default_async_extension_python/BUILD.gn +++ b/packages/core_extensions/default_async_extension_python/BUILD.gn @@ -22,8 +22,6 @@ ten_package("default_async_extension_python") { "addon.py.tent", "extension.py", "extension.py.tent", - "log.py", - "log.py.tent", "manifest.json", "manifest.json.tent", "property.json", diff --git a/packages/core_extensions/default_async_extension_python/BUILD_release.gn b/packages/core_extensions/default_async_extension_python/BUILD_release.gn index 5053ef7095..81b891ad60 100644 --- a/packages/core_extensions/default_async_extension_python/BUILD_release.gn +++ b/packages/core_extensions/default_async_extension_python/BUILD_release.gn @@ -12,7 +12,6 @@ ten_package("default_async_extension_python") { "__init__.py", "addon.py", "extension.py", - "log.py", "manifest.json", "property.json", "tests", diff --git a/packages/core_extensions/default_async_extension_python/BUILD_release.gn.tent b/packages/core_extensions/default_async_extension_python/BUILD_release.gn.tent index 186badc385..fda22fa87f 100644 --- a/packages/core_extensions/default_async_extension_python/BUILD_release.gn.tent +++ b/packages/core_extensions/default_async_extension_python/BUILD_release.gn.tent @@ -12,7 +12,6 @@ ten_package("{{package_name}}") { "__init__.py", "addon.py", "extension.py", - "log.py", "manifest.json", "property.json", "tests", diff --git a/packages/core_extensions/default_async_extension_python/__init__.py b/packages/core_extensions/default_async_extension_python/__init__.py index 2cc80a0ced..72593ab225 100644 --- a/packages/core_extensions/default_async_extension_python/__init__.py +++ b/packages/core_extensions/default_async_extension_python/__init__.py @@ -4,6 +4,3 @@ # See the LICENSE file for more information. # from . import addon -from .log import logger - -logger.info("default_async_extension_python extension loaded") diff --git a/packages/core_extensions/default_async_extension_python/__init__.py.tent b/packages/core_extensions/default_async_extension_python/__init__.py.tent index 9c752bfc8d..72593ab225 100644 --- a/packages/core_extensions/default_async_extension_python/__init__.py.tent +++ b/packages/core_extensions/default_async_extension_python/__init__.py.tent @@ -4,6 +4,3 @@ # See the LICENSE file for more information. # from . import addon -from .log import logger - -logger.info("{{package_name}} extension loaded") diff --git a/packages/core_extensions/default_async_extension_python/addon.py b/packages/core_extensions/default_async_extension_python/addon.py index d2e813b06b..f4d8f976a2 100644 --- a/packages/core_extensions/default_async_extension_python/addon.py +++ b/packages/core_extensions/default_async_extension_python/addon.py @@ -9,12 +9,11 @@ TenEnv, ) from .extension import DefaultAsyncExtension -from .log import logger @register_addon_as_extension("default_async_extension_python") class DefaultAsyncExtensionAddon(Addon): def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None: - logger.info("DefaultAsyncExtensionAddon on_create_instance") + ten_env.log_info("DefaultAsyncExtensionAddon on_create_instance") ten_env.on_create_instance_done(DefaultAsyncExtension(name), context) diff --git a/packages/core_extensions/default_async_extension_python/addon.py.tent b/packages/core_extensions/default_async_extension_python/addon.py.tent index 9c1d3fe19a..231e9f9f84 100644 --- a/packages/core_extensions/default_async_extension_python/addon.py.tent +++ b/packages/core_extensions/default_async_extension_python/addon.py.tent @@ -9,12 +9,11 @@ from ten import ( TenEnv, ) from .extension import {{class_name_prefix}}Extension -from .log import logger @register_addon_as_extension("{{package_name}}") class {{class_name_prefix}}ExtensionAddon(Addon): def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None: - logger.info("{{class_name_prefix}}ExtensionAddon on_create_instance") + ten_env.log_info("{{class_name_prefix}}ExtensionAddon on_create_instance") ten_env.on_create_instance_done({{class_name_prefix}}Extension(name), context) diff --git a/packages/core_extensions/default_async_extension_python/log.py b/packages/core_extensions/default_async_extension_python/log.py deleted file mode 100644 index 8980ea64df..0000000000 --- a/packages/core_extensions/default_async_extension_python/log.py +++ /dev/null @@ -1,20 +0,0 @@ -# -# This file is part of TEN Framework, an open source project. -# Licensed under the Apache License, Version 2.0. -# See the LICENSE file for more information. -# -import logging - -logger = logging.getLogger("default_async_extension_python") -logger.setLevel(logging.INFO) - -formatter_str = ( - "%(asctime)s - %(name)s - %(levelname)s - %(process)d - " - "[%(filename)s:%(lineno)d] - %(message)s" -) -formatter = logging.Formatter(formatter_str) - -console_handler = logging.StreamHandler() -console_handler.setFormatter(formatter) - -logger.addHandler(console_handler) diff --git a/packages/core_extensions/default_async_extension_python/log.py.tent b/packages/core_extensions/default_async_extension_python/log.py.tent deleted file mode 100644 index 5f9bd6b29f..0000000000 --- a/packages/core_extensions/default_async_extension_python/log.py.tent +++ /dev/null @@ -1,20 +0,0 @@ -# -# This file is part of TEN Framework, an open source project. -# Licensed under the Apache License, Version 2.0. -# See the LICENSE file for more information. -# -import logging - -logger = logging.getLogger("{{package_name}}") -logger.setLevel(logging.INFO) - -formatter_str = ( - "%(asctime)s - %(name)s - %(levelname)s - %(process)d - " - "[%(filename)s:%(lineno)d] - %(message)s" -) -formatter = logging.Formatter(formatter_str) - -console_handler = logging.StreamHandler() -console_handler.setFormatter(formatter) - -logger.addHandler(console_handler) diff --git a/packages/core_extensions/default_extension_python/BUILD.gn b/packages/core_extensions/default_extension_python/BUILD.gn index c53261f464..cb60ecee17 100644 --- a/packages/core_extensions/default_extension_python/BUILD.gn +++ b/packages/core_extensions/default_extension_python/BUILD.gn @@ -22,8 +22,6 @@ ten_package("default_extension_python") { "addon.py.tent", "extension.py", "extension.py.tent", - "log.py", - "log.py.tent", "manifest.json", "manifest.json.tent", "property.json", diff --git a/packages/core_extensions/default_extension_python/BUILD_release.gn b/packages/core_extensions/default_extension_python/BUILD_release.gn index 6fc11bee01..d949da3abb 100644 --- a/packages/core_extensions/default_extension_python/BUILD_release.gn +++ b/packages/core_extensions/default_extension_python/BUILD_release.gn @@ -12,7 +12,6 @@ ten_package("default_extension_python") { "__init__.py", "addon.py", "extension.py", - "log.py", "manifest.json", "property.json", "tests", diff --git a/packages/core_extensions/default_extension_python/BUILD_release.gn.tent b/packages/core_extensions/default_extension_python/BUILD_release.gn.tent index 186badc385..fda22fa87f 100644 --- a/packages/core_extensions/default_extension_python/BUILD_release.gn.tent +++ b/packages/core_extensions/default_extension_python/BUILD_release.gn.tent @@ -12,7 +12,6 @@ ten_package("{{package_name}}") { "__init__.py", "addon.py", "extension.py", - "log.py", "manifest.json", "property.json", "tests", diff --git a/packages/core_extensions/default_extension_python/__init__.py b/packages/core_extensions/default_extension_python/__init__.py index aa93ae4a01..72593ab225 100644 --- a/packages/core_extensions/default_extension_python/__init__.py +++ b/packages/core_extensions/default_extension_python/__init__.py @@ -4,6 +4,3 @@ # See the LICENSE file for more information. # from . import addon -from .log import logger - -logger.info("default_extension_python extension loaded") diff --git a/packages/core_extensions/default_extension_python/__init__.py.tent b/packages/core_extensions/default_extension_python/__init__.py.tent index 9c752bfc8d..72593ab225 100644 --- a/packages/core_extensions/default_extension_python/__init__.py.tent +++ b/packages/core_extensions/default_extension_python/__init__.py.tent @@ -4,6 +4,3 @@ # See the LICENSE file for more information. # from . import addon -from .log import logger - -logger.info("{{package_name}} extension loaded") diff --git a/packages/core_extensions/default_extension_python/addon.py b/packages/core_extensions/default_extension_python/addon.py index 8d405c61bb..699fa5a885 100644 --- a/packages/core_extensions/default_extension_python/addon.py +++ b/packages/core_extensions/default_extension_python/addon.py @@ -9,12 +9,11 @@ TenEnv, ) from .extension import DefaultExtension -from .log import logger @register_addon_as_extension("default_extension_python") class DefaultExtensionAddon(Addon): def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None: - logger.info("DefaultExtensionAddon on_create_instance") + ten_env.log_info("DefaultExtensionAddon on_create_instance") ten_env.on_create_instance_done(DefaultExtension(name), context) diff --git a/packages/core_extensions/default_extension_python/addon.py.tent b/packages/core_extensions/default_extension_python/addon.py.tent index 9c1d3fe19a..231e9f9f84 100644 --- a/packages/core_extensions/default_extension_python/addon.py.tent +++ b/packages/core_extensions/default_extension_python/addon.py.tent @@ -9,12 +9,11 @@ from ten import ( TenEnv, ) from .extension import {{class_name_prefix}}Extension -from .log import logger @register_addon_as_extension("{{package_name}}") class {{class_name_prefix}}ExtensionAddon(Addon): def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None: - logger.info("{{class_name_prefix}}ExtensionAddon on_create_instance") + ten_env.log_info("{{class_name_prefix}}ExtensionAddon on_create_instance") ten_env.on_create_instance_done({{class_name_prefix}}Extension(name), context) diff --git a/packages/core_extensions/default_extension_python/log.py b/packages/core_extensions/default_extension_python/log.py deleted file mode 100644 index 6b07e1ac83..0000000000 --- a/packages/core_extensions/default_extension_python/log.py +++ /dev/null @@ -1,20 +0,0 @@ -# -# This file is part of TEN Framework, an open source project. -# Licensed under the Apache License, Version 2.0. -# See the LICENSE file for more information. -# -import logging - -logger = logging.getLogger("default_extension_python") -logger.setLevel(logging.INFO) - -formatter_str = ( - "%(asctime)s - %(name)s - %(levelname)s - %(process)d - " - "[%(filename)s:%(lineno)d] - %(message)s" -) -formatter = logging.Formatter(formatter_str) - -console_handler = logging.StreamHandler() -console_handler.setFormatter(formatter) - -logger.addHandler(console_handler) diff --git a/packages/core_extensions/default_extension_python/log.py.tent b/packages/core_extensions/default_extension_python/log.py.tent deleted file mode 100644 index 5f9bd6b29f..0000000000 --- a/packages/core_extensions/default_extension_python/log.py.tent +++ /dev/null @@ -1,20 +0,0 @@ -# -# This file is part of TEN Framework, an open source project. -# Licensed under the Apache License, Version 2.0. -# See the LICENSE file for more information. -# -import logging - -logger = logging.getLogger("{{package_name}}") -logger.setLevel(logging.INFO) - -formatter_str = ( - "%(asctime)s - %(name)s - %(levelname)s - %(process)d - " - "[%(filename)s:%(lineno)d] - %(message)s" -) -formatter = logging.Formatter(formatter_str) - -console_handler = logging.StreamHandler() -console_handler.setFormatter(formatter) - -logger.addHandler(console_handler) diff --git a/tests/ten_runtime/integration/python/go_app_cythonize/go_app_cythonize_app/ten_packages/extension/default_extension_python/__init__.pyx b/tests/ten_runtime/integration/python/go_app_cythonize/go_app_cythonize_app/ten_packages/extension/default_extension_python/__init__.pyx index 347323e785..f3c731cdd5 100644 --- a/tests/ten_runtime/integration/python/go_app_cythonize/go_app_cythonize_app/ten_packages/extension/default_extension_python/__init__.pyx +++ b/tests/ten_runtime/integration/python/go_app_cythonize/go_app_cythonize_app/ten_packages/extension/default_extension_python/__init__.pyx @@ -1,4 +1 @@ from . import addon -from .log import logger - -logger.info("I am default extension python") diff --git a/tests/ten_runtime/integration/python/go_app_cythonize/go_app_cythonize_app/ten_packages/extension/default_extension_python/addon.pyx b/tests/ten_runtime/integration/python/go_app_cythonize/go_app_cythonize_app/ten_packages/extension/default_extension_python/addon.pyx index 9faddf34e8..3fa9935694 100644 --- a/tests/ten_runtime/integration/python/go_app_cythonize/go_app_cythonize_app/ten_packages/extension/default_extension_python/addon.pyx +++ b/tests/ten_runtime/integration/python/go_app_cythonize/go_app_cythonize_app/ten_packages/extension/default_extension_python/addon.pyx @@ -10,12 +10,11 @@ from ten import ( TenEnv, ) from .extension import DefaultExtension -from .log import logger @register_addon_as_extension("default_extension_python", __file__) class DefaultExtensionAddon(Addon): def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None: - logger.info("DefaultExtensionAddon on_create_instance") + ten_env.log_info("DefaultExtensionAddon on_create_instance") ten_env.on_create_instance_done(DefaultExtension(name), context) diff --git a/tests/ten_runtime/integration/python/go_app_partially_cythonize/go_app_partially_cythonize_app/ten_packages/extension/default_extension_python/__init__.py b/tests/ten_runtime/integration/python/go_app_partially_cythonize/go_app_partially_cythonize_app/ten_packages/extension/default_extension_python/__init__.py index eaf11c0844..178dc92b6a 100644 --- a/tests/ten_runtime/integration/python/go_app_partially_cythonize/go_app_partially_cythonize_app/ten_packages/extension/default_extension_python/__init__.py +++ b/tests/ten_runtime/integration/python/go_app_partially_cythonize/go_app_partially_cythonize_app/ten_packages/extension/default_extension_python/__init__.py @@ -5,6 +5,3 @@ # Refer to the "LICENSE" file in the root directory for more information. # from . import addon -from .log import logger - -logger.info("default_extension_python extension loaded") diff --git a/tests/ten_runtime/integration/python/go_app_partially_cythonize/go_app_partially_cythonize_app/ten_packages/extension/default_extension_python/addon.py b/tests/ten_runtime/integration/python/go_app_partially_cythonize/go_app_partially_cythonize_app/ten_packages/extension/default_extension_python/addon.py index 9faddf34e8..3fa9935694 100644 --- a/tests/ten_runtime/integration/python/go_app_partially_cythonize/go_app_partially_cythonize_app/ten_packages/extension/default_extension_python/addon.py +++ b/tests/ten_runtime/integration/python/go_app_partially_cythonize/go_app_partially_cythonize_app/ten_packages/extension/default_extension_python/addon.py @@ -10,12 +10,11 @@ TenEnv, ) from .extension import DefaultExtension -from .log import logger @register_addon_as_extension("default_extension_python", __file__) class DefaultExtensionAddon(Addon): def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None: - logger.info("DefaultExtensionAddon on_create_instance") + ten_env.log_info("DefaultExtensionAddon on_create_instance") ten_env.on_create_instance_done(DefaultExtension(name), context) diff --git a/tests/ten_runtime/integration/python/standalone_test_python/default_extension_python/__init__.py b/tests/ten_runtime/integration/python/standalone_test_python/default_extension_python/__init__.py index eaf11c0844..178dc92b6a 100644 --- a/tests/ten_runtime/integration/python/standalone_test_python/default_extension_python/__init__.py +++ b/tests/ten_runtime/integration/python/standalone_test_python/default_extension_python/__init__.py @@ -5,6 +5,3 @@ # Refer to the "LICENSE" file in the root directory for more information. # from . import addon -from .log import logger - -logger.info("default_extension_python extension loaded") diff --git a/tests/ten_runtime/integration/python/standalone_test_python/default_extension_python/addon.py b/tests/ten_runtime/integration/python/standalone_test_python/default_extension_python/addon.py index 132eed89e0..a1c0872467 100644 --- a/tests/ten_runtime/integration/python/standalone_test_python/default_extension_python/addon.py +++ b/tests/ten_runtime/integration/python/standalone_test_python/default_extension_python/addon.py @@ -10,12 +10,11 @@ TenEnv, ) from .extension import DefaultExtension -from .log import logger @register_addon_as_extension("default_extension_python") class DefaultExtensionAddon(Addon): def on_create_instance(self, ten_env: TenEnv, name: str, context) -> None: - logger.info("DefaultExtensionAddon on_create_instance") + ten_env.log_info("DefaultExtensionAddon on_create_instance") ten_env.on_create_instance_done(DefaultExtension(name), context)