Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/xdg_logs #210

Merged
merged 2 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mycroft/audio/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
from ovos_config.locale import setup_locale
from mycroft.lock import Lock as PIDLock # Create/Support PID locking file
from mycroft.util import reset_sigint_handler, wait_for_exit_signal, \
check_for_signal

check_for_signal, init_service_logger
service = None # Added for backwards-compat.


def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping,
watchdog=lambda: None):
global service
"""Start the Audio Service and connect to the Message Bus"""
init_service_logger("audio")
reset_sigint_handler()
check_for_signal("isSpeaking")
PIDLock("audio")
Expand Down
3 changes: 2 additions & 1 deletion mycroft/client/enclosure/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
to be a drop in replacement for mycroft-core

"""

from mycroft.util import init_service_logger
from mycroft.deprecated.enclosure.main import *

if __name__ == "__main__":
init_service_logger("enclosure")
main()
3 changes: 2 additions & 1 deletion mycroft/client/speech/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
from mycroft.lock import Lock as PIDLock # Create/Support PID locking file
from mycroft.util import (
reset_sigint_handler,
wait_for_exit_signal
wait_for_exit_signal, init_service_logger
)


def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping,
watchdog=lambda: None):
init_service_logger("voice")
reset_sigint_handler()
PIDLock("voice")
setup_locale()
Expand Down
2 changes: 2 additions & 0 deletions mycroft/client/text/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Text client moved into ovos_cli_client package
"""
from ovos_cli_client.__main__ import main
from mycroft.util import init_service_logger


if __name__ == "__main__":
init_service_logger("cli")
main()
3 changes: 2 additions & 1 deletion mycroft/gui/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ovos_config.locale import setup_locale
from mycroft.gui.service import GUIService
from mycroft.util import wait_for_exit_signal, reset_sigint_handler
from mycroft.util import wait_for_exit_signal, reset_sigint_handler, init_service_logger
from mycroft.util.log import LOG


Expand All @@ -17,6 +17,7 @@ def on_error(e='Unknown'):


def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping):
init_service_logger("gui")
LOG.debug("GUI websocket created")
try:
reset_sigint_handler()
Expand Down
3 changes: 2 additions & 1 deletion mycroft/listener/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
from mycroft.lock import Lock as PIDLock # Create/Support PID locking file
from mycroft.util import (
reset_sigint_handler,
wait_for_exit_signal
wait_for_exit_signal, init_service_logger
)


def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping,
watchdog=lambda: None):
init_service_logger("voice")
reset_sigint_handler()
PIDLock("voice")
setup_locale()
Expand Down
3 changes: 2 additions & 1 deletion mycroft/messagebus/service/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from mycroft.util import (
reset_sigint_handler,
create_daemon,
wait_for_exit_signal
wait_for_exit_signal, init_service_logger
)
from mycroft.util.log import LOG
from tornado import web, ioloop
Expand All @@ -42,6 +42,7 @@ def on_stopping():


def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping):
init_service_logger("bus")
LOG.info('Starting message bus service...')
reset_sigint_handler()
config = load_message_bus_config()
Expand Down
3 changes: 2 additions & 1 deletion mycroft/skills/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from mycroft.util import (
reset_sigint_handler,
start_message_bus_client,
wait_for_exit_signal
wait_for_exit_signal, init_service_logger
)
from mycroft.util.log import LOG

Expand All @@ -44,6 +44,7 @@ def main(alive_hook=on_alive, started_hook=on_started, ready_hook=on_ready,
Returns:
SkillManager instance or None if it couldn't be initialized
"""
init_service_logger("skills")
reset_sigint_handler()
# Create PID file, prevent multiple instances of this service
mycroft.lock.Lock('skills')
Expand Down
14 changes: 14 additions & 0 deletions mycroft/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,17 @@
from mycroft.util.signal import check_for_signal, create_signal, \
get_ipc_directory
from mycroft.util.platform import get_arch
from ovos_config import Configuration


def init_service_logger(service_name):
# this is makes all logs from this service be configured to write to service_name.log file
# if this is not called in every __main__.py entrypoint logs will be written
# to a generic OVOS.log file shared across all services
_cfg = Configuration()
_log_level = _cfg.get("log_level", "INFO")
_logs_conf = _cfg.get("logs") or {}
_logs_conf["level"] = _log_level
LOG.name = service_name
LOG.init(_logs_conf) # read log level from config

1 change: 1 addition & 0 deletions mycroft/util/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
def getLogger(name="MYCROFT"):
"""Depreciated. Use LOG instead"""
return LOG

2 changes: 1 addition & 1 deletion requirements/minimal.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
requests~=2.26
mycroft-messagebus-client~=0.9,!=0.9.2,!=0.9.3
combo-lock~=0.2
ovos-utils~=0.0, >=0.0.23
ovos-utils~=0.0, >=0.0.25a8
ovos-plugin-manager~=0.0, >=0.0.19a4
ovos-config~=0.0,>=0.0.5a5
python-dateutil~=2.6
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ watchdog

ovos_backend_client~=0.0, >=0.0.5a3
ovos-config~=0.0,>=0.0.5a5
ovos-utils~=0.0, >=0.0.23
ovos-utils~=0.0, >=0.0.25a8
ovos-plugin-manager~=0.0, >=0.0.19a4
ovos-stt-plugin-server~=0.0, >=0.0.2
ovos-tts-plugin-mimic~=0.2, >=0.2.6
Expand Down
2 changes: 1 addition & 1 deletion start-bigscreen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function launch-background() {
fi
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this script being added to this repo, but it should be removed, launchers do not belong here specially if platform specific... in general launch.sh scripts are not recommended, setup.py provides proper entrypoints when installed, please use those

@AIIX not sure if you are using it, will let you deprecate this cleanly instead of removing it now


# Launch process in background, sending logs to standard location
python3 -m ${_module} $_params >> /var/log/mycroft/${1}.log 2>&1 &
python3 -m ${_module} $_params &
}

function launch-all() {
Expand Down
4 changes: 2 additions & 2 deletions start-mycroft.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ function launch-background() {
echo "Starting background service $1"
fi

# Launch process in background, sending logs to standard location
python3 -m ${_module} $_params >> /var/log/mycroft/${1}.log 2>&1 &
# Launch process in background
python3 -m ${_module} $_params &
}

function launch-all() {
Expand Down