From c56e968d581b9cc1edbb0c2822a2f809470ff29f Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Wed, 9 Jul 2014 13:17:44 -0400 Subject: Add logging to utils. --- os_net_config/utils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'os_net_config/utils.py') diff --git a/os_net_config/utils.py b/os_net_config/utils.py index 0254d45..a2df823 100644 --- a/os_net_config/utils.py +++ b/os_net_config/utils.py @@ -14,6 +14,11 @@ # License for the specific language governing permissions and limitations # under the License. +import logging + + +logger = logging.getLogger(__name__) + def write_config(filename, data): with open(filename, "w") as f: @@ -25,8 +30,13 @@ def get_file_data(filename): with open(filename, "r") as f: return f.read() except IOError: + logger.error("Error reading file: %s" % filename) return "" def diff(filename, data): - return not get_file_data(filename) == data + file_data = get_file_data(filename) + logger.debug("Diff file data:\n%s" % file_data) + logger.debug("Diff data:\n%s" % data) + # convert to string as JSON may have unicode in it + return not file_data == data -- cgit 1.2.3-korg