From 7afd4e3209774650b769166dd168830ce4d266ae Mon Sep 17 00:00:00 2001 From: Mike Gray Date: Tue, 30 Jan 2024 22:02:13 -0600 Subject: [PATCH 1/4] chore: clean up types, address name overwrite --- ovos_utils/log.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ovos_utils/log.py b/ovos_utils/log.py index 86c30048..423980e6 100644 --- a/ovos_utils/log.py +++ b/ovos_utils/log.py @@ -79,13 +79,13 @@ class LOG: formatter = logging.Formatter(fmt, datefmt) max_bytes = 50000000 backup_count = 3 - name = os.getenv("OVOS_DEFAULT_LOG_NAME") or 'OVOS' + name = os.getenv("OVOS_DEFAULT_LOG_NAME") or "OVOS" level = os.getenv("OVOS_DEFAULT_LOG_LEVEL") or "INFO" diagnostic_mode = False _loggers = {} @classmethod - def __init__(cls, name='OVOS'): + def __init__(cls, name=name): cls.name = name @classmethod @@ -226,9 +226,9 @@ def init_service_logger(service_name): def log_deprecation(log_message: str = "DEPRECATED", deprecation_version: str = "Unknown", - func_name: str = None, - func_module: str = None, - excluded_package_refs: List[str] = None): + func_name: str = "", + func_module: str = "", + excluded_package_refs: List[str] = [""]): """ Log a deprecation warning with information for the call outside the module that is generating the warning @@ -354,6 +354,6 @@ def get_available_logs(directories: Optional[List[str]] = None) -> List[str]: Returns: list of log files """ - directories = directories or get_log_paths() + directories = directories or list(get_log_paths()) return [Path(f).stem for path in directories for f in os.listdir(path) if Path(f).suffix == ".log"] From d3272ccf791730db6497324455174008302a3126 Mon Sep 17 00:00:00 2001 From: Mike Gray Date: Sat, 9 Mar 2024 22:44:02 -0600 Subject: [PATCH 2/4] chore(py)!: drop python 3.7 support --- .github/workflows/build_tests.yml | 6 +++--- .github/workflows/unit_tests.yml | 6 +++--- README.md => readme.md | 0 3 files changed, 6 insertions(+), 6 deletions(-) rename README.md => readme.md (100%) diff --git a/.github/workflows/build_tests.yml b/.github/workflows/build_tests.yml index 15be9921..eb9682f6 100644 --- a/.github/workflows/build_tests.yml +++ b/.github/workflows/build_tests.yml @@ -24,12 +24,12 @@ jobs: strategy: max-parallel: 2 matrix: - python-version: [ 3.7, 3.8, 3.9, "3.10" ] + python-version: [ 3.8, 3.9, "3.10", "3.11" ] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Build Tools diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index a24f52ef..fe0cc51e 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -37,12 +37,12 @@ jobs: strategy: max-parallel: 2 matrix: - python-version: [ 3.8, 3.9, "3.10" ] + python-version: [ 3.8, 3.9, "3.10", "3.11" ] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install System Dependencies diff --git a/README.md b/readme.md similarity index 100% rename from README.md rename to readme.md From 0c9e5de0e0360b73cfc79ffbb5484d2690994b64 Mon Sep 17 00:00:00 2001 From: Mike Gray Date: Sat, 9 Mar 2024 22:49:17 -0600 Subject: [PATCH 3/4] silly git tricks --- readme.md | 87 ------------------------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 readme.md diff --git a/readme.md b/readme.md deleted file mode 100644 index 7dd896e6..00000000 --- a/readme.md +++ /dev/null @@ -1,87 +0,0 @@ -# OVOS-utils - -collection of simple utilities for use across the mycroft ecosystem - -## Install - -```bash -pip install ovos_utils -``` - -## Commandline scripts -### ovos-logs - Small helper tool to quickly navigate the logs, create slices and quickview errors - ---------------- -- **ovos-logs slice [options]** - - **Slice logs of a given time period. Defaults on the last service start (`-s`) until now (`-u`)** - - _Different logs can be picked using the `-l` option. All logs will be included if not specified._ - _Optionally the directory where the logs are stored (`-p`) and the file where the slices should be dumped (`-f`) can be specified._ - - - _[ex: `ovos-logs slice`]_ - _Slice all logs from service start up until now._ - - _[ex: `ovos-logs slice -s 17:05:20 -u 17:05:25`]_ - _Slice all logs from 17:05:20 until 17:05:25._ - _**no logs in that timeframe in other present logs_ - Screenshot 2023-12-25 185004 - - _[ex: `ovos-logs slice -s 17:05:20 -u 17:05:25 -l skills`]_ - _Slice skills.log from 17:05:20 until 17:05:25._ - - _[ex: `ovos-logs slice -s 17:05:20 -u 17:05:25 -f ~/testslice.log`]_ - _Slice the logs from 17:05:20 until 17:05:25 on all log files and dump the slices in the file ~/testslice.log (default: `~/slice_.log`)._ - Screenshot 2023-12-25 190732 --------------- - -- **ovos-logs list [-e|-w|-d|-x] [options]** - - **List logs by severity (error/warning/debug/exception). A log level has to be specified - more than one can be listed** - - _A start and end date can be specified using the `-s` and `-u` options. Defaults to the last service start until now._ - _Different logs can be picked using the `-l` option. All logs will be included if not specified._ - _Optionally, the directory where the logs are stored (`-p`) and the file where the slices should be dumped (`-f`) can be passed as arguments._ - - _[ex: `ovos-logs list -x`]_ - _List the logs with level EXCEPTION (plus tracebacks) from the last service start until now._ - Screenshot 2023-12-25 184321 - - _[ex: `ovos-logs list -w -e -s 20-12-2023 -l bus -l skills`]_ - _List the logs with level WARNING and ERROR from the 20th of December 2023 until now from the logs bus.log and skills.log._ - Screenshot 2023-12-25 173739 ---------------------- - -- **ovos-logs reduce [options]** - - **Downsize logs to a given size (in bytes) or remove entries before a given date.** - - _Different logs can be included using the `-l` option. If not specified, all logs will be included._ - _Optionally the directory where the logs are stored (`-p`) can be specified._ - - _[ex: `ovos-logs reduce`]_ - _Downsize all logs to 0 bytes_ - - _[ex: `ovos-logs reduce -s 1000000`]_ - _Downsize all logs to ~1MB (latest logs)_ - - _[ex: `ovos-logs reduce -d "1-12-2023 17:00"`]_ - _Downsize all logs to entries after the specified date/time_ - - _[ex: `ovos-logs reduce -s 1000000 -l skills -l bus`]_ - _Downsize skills.log and bus.log to ~1MB (latest logs)_ - ---------------------- - -- **ovos-logs show -l [servicelog]** - - **Show logs** - - _[ex: `ovos-logs show -l bus`]_ - _Show the logs from bus.log._ - - _[ex: wrong servicelog]_ - _**logs shown depending on the logs present in the folder_ - From 3ae4825f1e223f08557a808511ebdb3ea95a1e68 Mon Sep 17 00:00:00 2001 From: Mike Gray Date: Sat, 9 Mar 2024 22:49:54 -0600 Subject: [PATCH 4/4] README changes --- README.md | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..41d27d2d --- /dev/null +++ b/README.md @@ -0,0 +1,87 @@ +# OVOS-utils + +A collection of simple utilities for use across the OpenVoiceOS ecosystem. + +## Install + +```bash +pip install ovos_utils +``` + +## Commandline scripts +### ovos-logs + Small helper tool to quickly navigate the logs, create slices and quickview errors + +--------------- +- **ovos-logs slice [options]** + + **Slice logs of a given time period. Defaults on the last service start (`-s`) until now (`-u`)** + + _Different logs can be picked using the `-l` option. All logs will be included if not specified._ + _Optionally the directory where the logs are stored (`-p`) and the file where the slices should be dumped (`-f`) can be specified._ + + + _[ex: `ovos-logs slice`]_ + _Slice all logs from service start up until now._ + + _[ex: `ovos-logs slice -s 17:05:20 -u 17:05:25`]_ + _Slice all logs from 17:05:20 until 17:05:25._ + _**no logs in that timeframe in other present logs_ + Screenshot 2023-12-25 185004 + + _[ex: `ovos-logs slice -s 17:05:20 -u 17:05:25 -l skills`]_ + _Slice skills.log from 17:05:20 until 17:05:25._ + + _[ex: `ovos-logs slice -s 17:05:20 -u 17:05:25 -f ~/testslice.log`]_ + _Slice the logs from 17:05:20 until 17:05:25 on all log files and dump the slices in the file ~/testslice.log (default: `~/slice_.log`)._ + Screenshot 2023-12-25 190732 +-------------- + +- **ovos-logs list [-e|-w|-d|-x] [options]** + + **List logs by severity (error/warning/debug/exception). A log level has to be specified - more than one can be listed** + + _A start and end date can be specified using the `-s` and `-u` options. Defaults to the last service start until now._ + _Different logs can be picked using the `-l` option. All logs will be included if not specified._ + _Optionally, the directory where the logs are stored (`-p`) and the file where the slices should be dumped (`-f`) can be passed as arguments._ + + _[ex: `ovos-logs list -x`]_ + _List the logs with level EXCEPTION (plus tracebacks) from the last service start until now._ + Screenshot 2023-12-25 184321 + + _[ex: `ovos-logs list -w -e -s 20-12-2023 -l bus -l skills`]_ + _List the logs with level WARNING and ERROR from the 20th of December 2023 until now from the logs bus.log and skills.log._ + Screenshot 2023-12-25 173739 +--------------------- + +- **ovos-logs reduce [options]** + + **Downsize logs to a given size (in bytes) or remove entries before a given date.** + + _Different logs can be included using the `-l` option. If not specified, all logs will be included._ + _Optionally the directory where the logs are stored (`-p`) can be specified._ + + _[ex: `ovos-logs reduce`]_ + _Downsize all logs to 0 bytes_ + + _[ex: `ovos-logs reduce -s 1000000`]_ + _Downsize all logs to ~1MB (latest logs)_ + + _[ex: `ovos-logs reduce -d "1-12-2023 17:00"`]_ + _Downsize all logs to entries after the specified date/time_ + + _[ex: `ovos-logs reduce -s 1000000 -l skills -l bus`]_ + _Downsize skills.log and bus.log to ~1MB (latest logs)_ + +--------------------- + +- **ovos-logs show -l [servicelog]** + + **Show logs** + + _[ex: `ovos-logs show -l bus`]_ + _Show the logs from bus.log._ + + _[ex: wrong servicelog]_ + _**logs shown depending on the logs present in the folder_ +