summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorDaniel Watkins <daniel@daniel-watkins.co.uk>2019-09-09 19:12:21 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-09-09 19:12:21 +0000
commit476050b46021130654a7417bbb41647a5214dbcc (patch)
treef2d291417f9a2df418cb5dd54c3d66b127d00905 /cloudinit
parent385232dc8da6532b54342cd11e6d822ff7cd3e5a (diff)
downloadvyos-cloud-init-476050b46021130654a7417bbb41647a5214dbcc.tar.gz
vyos-cloud-init-476050b46021130654a7417bbb41647a5214dbcc.zip
atomic_helper: add DEBUG logging to write_file
LP: #1843276
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/atomic_helper.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/cloudinit/atomic_helper.py b/cloudinit/atomic_helper.py
index 587b9945..1f61faa2 100644
--- a/cloudinit/atomic_helper.py
+++ b/cloudinit/atomic_helper.py
@@ -1,11 +1,13 @@
# This file is part of cloud-init. See LICENSE file for license information.
import json
+import logging
import os
import stat
import tempfile
_DEF_PERMS = 0o644
+LOG = logging.getLogger(__name__)
def write_file(filename, content, mode=_DEF_PERMS,
@@ -23,6 +25,10 @@ def write_file(filename, content, mode=_DEF_PERMS,
try:
tf = tempfile.NamedTemporaryFile(dir=os.path.dirname(filename),
delete=False, mode=omode)
+ LOG.debug(
+ "Atomically writing to file %s (via temporary file %s) - %s: [%o]"
+ " %d bytes/chars",
+ filename, tf.name, omode, mode, len(content))
tf.write(content)
tf.close()
os.chmod(tf.name, mode)