From 3d89414df6881101d92eea464056ecab9b0818c8 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Mon, 11 Dec 2023 13:54:13 -0800 Subject: [PATCH] Use standard logging config Move config env handling and logging to package init --- docker_overlay/etc/neon/neon.yaml | 9 +++++++++ neon_iris/__init__.py | 7 +++++++ neon_iris/cli.py | 5 ----- neon_iris/web_client.py | 2 -- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docker_overlay/etc/neon/neon.yaml b/docker_overlay/etc/neon/neon.yaml index cdb38cb..f3f8e79 100644 --- a/docker_overlay/etc/neon/neon.yaml +++ b/docker_overlay/etc/neon/neon.yaml @@ -35,3 +35,12 @@ location: name: Pacific Standard Time dstOffset: 3600000 offset: -28800000 + +logs: + name: iris + level: INFO + level_overrides: + error: + - pika + warning: + - filelock \ No newline at end of file diff --git a/neon_iris/__init__.py b/neon_iris/__init__.py index d782cbb..1efd3a5 100644 --- a/neon_iris/__init__.py +++ b/neon_iris/__init__.py @@ -23,3 +23,10 @@ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from os import environ +from neon_utils.log_utils import init_log + +environ.setdefault("OVOS_CONFIG_BASE_FOLDER", "neon") +environ.setdefault("OVOS_CONFIG_FILENAME", "diana.yaml") +init_log(log_name="iris") diff --git a/neon_iris/cli.py b/neon_iris/cli.py index 76353d5..582ab83 100644 --- a/neon_iris/cli.py +++ b/neon_iris/cli.py @@ -29,7 +29,6 @@ import click -from os import environ from os.path import expanduser, isfile from time import sleep from click_default_group import DefaultGroup @@ -38,10 +37,6 @@ from neon_iris.util import load_config_file from neon_iris.version import __version__ -environ.setdefault("OVOS_CONFIG_BASE_FOLDER", "neon") -environ.setdefault("OVOS_CONFIG_FILENAME", "diana.yaml") -# TODO: Define default config file from this package - def _print_config(): from ovos_config.config import Configuration diff --git a/neon_iris/web_client.py b/neon_iris/web_client.py index 60a3dc8..b33fd66 100644 --- a/neon_iris/web_client.py +++ b/neon_iris/web_client.py @@ -59,8 +59,6 @@ def __init__(self, lang: str = None): makedirs(self._audio_path) self.default_lang = lang or self.config.get('default_lang') self.chat_ui = gradio.Blocks() - LOG.name = "iris" - LOG.init(self.config.get("logs")) def get_lang(self, session_id: str): if session_id and session_id in self._profiles: