From 2dd4d648b857b77ef2335570ba0655f1c316f470 Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Tue, 14 Mar 2023 12:06:50 +0000 Subject: [PATCH] change sessionid to uuid-like format --- openbb_terminal/loggers.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/openbb_terminal/loggers.py b/openbb_terminal/loggers.py index cdd09b0d4adf..04abb1ebe0cb 100644 --- a/openbb_terminal/loggers.py +++ b/openbb_terminal/loggers.py @@ -5,6 +5,7 @@ import logging import sys import time +import uuid from pathlib import Path from typing import Optional @@ -47,8 +48,6 @@ logger = logging.getLogger(__name__) -START_TIMESTAMP = int(time.time()) - def get_app_id() -> str: """UUID of the current installation.""" @@ -69,6 +68,12 @@ def get_app_id() -> str: return app_id +def get_session_id() -> str: + """UUID of the current session.""" + session_id = str(uuid.uuid4()) + "-" + str(int(time.time())) + return session_id + + def get_commit_hash(use_env=True) -> str: """Get Commit Short Hash""" @@ -157,7 +162,6 @@ def setup_handlers(settings: Settings): def setup_logging( app_name: Optional[str] = None, frequency: Optional[str] = None, - session_id: Optional[str] = None, verbosity: Optional[int] = None, ) -> None: """Setup Logging""" @@ -166,7 +170,7 @@ def setup_logging( commit_hash = get_commit_hash() name = app_name or LOGGING_APP_NAME identifier = get_app_id() - session_id = session_id or str(START_TIMESTAMP) + session_id = get_session_id() user_id = get_user_uuid() # AWSSettings