diff options
author | Daniel Watkins <daniel@daniel-watkins.co.uk> | 2019-09-09 19:12:21 +0000 |
---|---|---|
committer | Server Team CI Bot <josh.powers+server-team-bot@canonical.com> | 2019-09-09 19:12:21 +0000 |
commit | 476050b46021130654a7417bbb41647a5214dbcc (patch) | |
tree | f2d291417f9a2df418cb5dd54c3d66b127d00905 /cloudinit/atomic_helper.py | |
parent | 385232dc8da6532b54342cd11e6d822ff7cd3e5a (diff) | |
download | vyos-cloud-init-476050b46021130654a7417bbb41647a5214dbcc.tar.gz vyos-cloud-init-476050b46021130654a7417bbb41647a5214dbcc.zip |
atomic_helper: add DEBUG logging to write_file
LP: #1843276
Diffstat (limited to 'cloudinit/atomic_helper.py')
-rw-r--r-- | cloudinit/atomic_helper.py | 6 |
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) |