mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-06-07 23:35:49 +08:00
[Feature] CLI logging (#6487)
* remove old logging references * cli as logging subapp option * changing the subapp to the cli on init
This commit is contained in:
34
cli/openbb_cli/utils/utils.py
Normal file
34
cli/openbb_cli/utils/utils.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""OpenBB Platform CLI utilities."""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
HOME_DIRECTORY = Path.home()
|
||||
OPENBB_PLATFORM_DIRECTORY = Path(HOME_DIRECTORY, ".openbb_platform")
|
||||
SYSTEM_SETTINGS_PATH = Path(OPENBB_PLATFORM_DIRECTORY, "system_settings.json")
|
||||
|
||||
|
||||
def change_logging_sub_app() -> str:
|
||||
"""Build OpenBB Platform setting files."""
|
||||
with open(SYSTEM_SETTINGS_PATH) as file:
|
||||
system_settings = json.load(file)
|
||||
|
||||
initial_logging_sub_app = system_settings.get("logging_sub_app", "")
|
||||
|
||||
system_settings["logging_sub_app"] = "cli"
|
||||
|
||||
with open(SYSTEM_SETTINGS_PATH, "w") as file:
|
||||
json.dump(system_settings, file, indent=4)
|
||||
|
||||
return initial_logging_sub_app
|
||||
|
||||
|
||||
def reset_logging_sub_app(initial_logging_sub_app: str):
|
||||
"""Reset OpenBB Platform setting files."""
|
||||
with open(SYSTEM_SETTINGS_PATH) as file:
|
||||
system_settings = json.load(file)
|
||||
|
||||
system_settings["logging_sub_app"] = initial_logging_sub_app
|
||||
|
||||
with open(SYSTEM_SETTINGS_PATH, "w") as file:
|
||||
json.dump(system_settings, file, indent=4)
|
||||
Reference in New Issue
Block a user