summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2014-07-09 13:17:44 -0400
committerDan Prince <dprince@redhat.com>2014-07-09 13:17:44 -0400
commitc56e968d581b9cc1edbb0c2822a2f809470ff29f (patch)
tree4562a3330f55923c60622cf4d5ab1e67476c2770
parentb5a608b0ef9f1b675534183faa1461a91a0226b3 (diff)
Add logging to utils.
-rw-r--r--os_net_config/utils.py12
1 files changed, 11 insertions, 1 deletions
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