Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
fix/update logs dir (#2)
Browse files Browse the repository at this point in the history
* fix/update logs dir

new XDG default location + old location monitoring

* dont overthink it
  • Loading branch information
JarbasAl authored Oct 8, 2022
1 parent d496123 commit fc93756
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions ovos_cli_client/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
import os.path
import signal
import sys
from os.path import exists
from ovos_config import Configuration
from ovos_utils.signal import get_ipc_directory

from ovos_utils.log import LOG
from ovos_cli_client.text_client import (
load_settings, save_settings, simple_cli, gui_main,
start_log_monitor, start_mic_monitor, connect_to_mycroft,
ctrl_c_handler
)
from ovos_config.meta import get_xdg_base
from ovos_utils.xdg_utils import xdg_state_home

sys.stdout = io.StringIO()
sys.stderr = io.StringIO()
Expand All @@ -44,15 +47,27 @@ def main():
# Monitor system logs
config = Configuration()

legacy_path = "/var/log/mycroft"

if 'log_dir' not in config:
config["log_dir"] = "/var/log/mycroft"
config["log_dir"] = f"{xdg_state_home()}/{get_xdg_base()}/logs"

log_dir = os.path.expanduser(config['log_dir'])
for f in os.listdir(log_dir):
if not f.endswith(".log"):
continue
start_log_monitor(os.path.join(log_dir, f))

# also monitor legacy path for compat
if log_dir != legacy_path and exists(legacy_path):
LOG.warning(
f"this installation seems to also contain logs in the legacy directory {legacy_path}, "
f"please start using {log_dir}")
for f in os.listdir(legacy_path):
if not f.endswith(".log"):
continue
start_log_monitor(os.path.join(legacy_path, f))

# Monitor IPC file containing microphone level info
start_mic_monitor(os.path.join(get_ipc_directory(), "mic_level"))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def package_files(directory):
version="0.0.1",
packages=['ovos_cli_client'],
url='https://github.com/OpenVoiceOS/ovos_cli_client',
install_requires=["ovos_utils"],
install_requires=["ovos_utils>=0.0.25a8"],
package_data={'': package_files('ovos_cli_client')},
include_package_data=True,
license='Apache',
Expand Down

0 comments on commit fc93756

Please sign in to comment.