Skip to content

Commit

Permalink
minor utils fix (#98)
Browse files Browse the repository at this point in the history
* minor utils fix

* bump ovos utils
  • Loading branch information
JarbasAl committed Feb 8, 2023
1 parent d1b069e commit 7976b7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ovos_utils/fingerprinting.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,15 @@ def core_supports_xdg():


def get_mycroft_version():
try:
try: # ovos
from mycroft.version import OVOS_VERSION_STR
return OVOS_VERSION_STR
except ImportError:
pass
try: # mycroft
from mycroft.version import CORE_VERSION_STR
return CORE_VERSION_STR
except:
except ImportError:
pass

root = search_mycroft_core_location()
Expand Down
14 changes: 14 additions & 0 deletions ovos_utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,17 @@ def error(cls, *args, **kwargs):
@classmethod
def exception(cls, *args, **kwargs):
cls._get_real_logger().exception(*args, **kwargs)


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
from ovos_config import Configuration

_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

0 comments on commit 7976b7c

Please sign in to comment.