diff options
author | John Estabrook <jestabro@vyos.io> | 2024-06-19 20:49:11 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2024-09-11 12:00:07 -0500 |
commit | fe810a0fe31668e64031e6fc8e2cc386b551ae6e (patch) | |
tree | 2190a3937d0286c6de67d28947d437953738abb3 | |
parent | b5db9395ed576ef97b1692ca66c00900c532d6a1 (diff) | |
download | vyos-1x-fe810a0fe31668e64031e6fc8e2cc386b551ae6e.tar.gz vyos-1x-fe810a0fe31668e64031e6fc8e2cc386b551ae6e.zip |
migration: T6007: write configtree operations to log
(cherry picked from commit 9388f62783849854fb9ca9852b5dc285932cf562)
-rw-r--r-- | python/vyos/configtree.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py index afd6e030b..5775070e2 100644 --- a/python/vyos/configtree.py +++ b/python/vyos/configtree.py @@ -15,6 +15,7 @@ import os import re import json +import logging from ctypes import cdll, c_char_p, c_void_p, c_int, c_bool @@ -161,6 +162,8 @@ class ConfigTree(object): self.__version = '' self.__migration = os.environ.get('VYOS_MIGRATION') + if self.__migration: + self.migration_log = logging.getLogger('vyos.migrate') def __del__(self): if self.__config is not None: @@ -215,7 +218,7 @@ class ConfigTree(object): self.__set_add_value(self.__config, path_str, str(value).encode()) if self.__migration: - print(f"- op: set path: {path} value: {value} replace: {replace}") + self.migration_log.info(f"- op: set path: {path} value: {value} replace: {replace}") def delete(self, path): check_path(path) @@ -226,7 +229,7 @@ class ConfigTree(object): raise ConfigTreeError(f"Path doesn't exist: {path}") if self.__migration: - print(f"- op: delete path: {path}") + self.migration_log.info(f"- op: delete path: {path}") def delete_value(self, path, value): check_path(path) @@ -242,7 +245,7 @@ class ConfigTree(object): raise ConfigTreeError() if self.__migration: - print(f"- op: delete_value path: {path} value: {value}") + self.migration_log.info(f"- op: delete_value path: {path} value: {value}") def rename(self, path, new_name): check_path(path) @@ -258,7 +261,7 @@ class ConfigTree(object): raise ConfigTreeError("Path [{}] doesn't exist".format(path)) if self.__migration: - print(f"- op: rename old_path: {path} new_path: {new_path}") + self.migration_log.info(f"- op: rename old_path: {path} new_path: {new_path}") def copy(self, old_path, new_path): check_path(old_path) @@ -275,7 +278,7 @@ class ConfigTree(object): raise ConfigTreeError(msg) if self.__migration: - print(f"- op: copy old_path: {old_path} new_path: {new_path}") + self.migration_log.info(f"- op: copy old_path: {old_path} new_path: {new_path}") def exists(self, path): check_path(path) |