diff options
author | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2009-01-05 00:51:58 -0500 |
---|---|---|
committer | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2009-01-05 00:51:58 -0500 |
commit | 6de41224c5133ced1124521ea0b212d1f6f2c2c4 (patch) | |
tree | a8c9f95d158c81d19a4f0aa7bce32beda2d511bb /base | |
parent | 30fe0400ab1bb17b892235ae96c5e704204d4fc2 (diff) | |
download | fedora-devshell-6de41224c5133ced1124521ea0b212d1f6f2c2c4.tar.gz fedora-devshell-6de41224c5133ced1124521ea0b212d1f6f2c2c4.tar.xz fedora-devshell-6de41224c5133ced1124521ea0b212d1f6f2c2c4.zip |
Adds headers and footers to log files
Diffstat (limited to 'base')
-rw-r--r-- | base/util.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/base/util.py b/base/util.py index d4a6475..ec72594 100644 --- a/base/util.py +++ b/base/util.py @@ -19,6 +19,7 @@ from __future__ import with_statement from contextlib import contextmanager +from datetime import datetime from os import chdir, getcwd, remove from os import symlink as sym from os.path import abspath, lexists, isdir, islink, isfile @@ -37,6 +38,14 @@ def pwd(dir): log.debug('changing dir to %s' % old_dir) chdir(old_dir) +@contextmanager +def log_file(fname): + with file(fname, 'a') as fout: + fout.write("-- Beginning log of %s at %s --\n" % (fname, datetime.now().isoformat(' '))) + fout.flush() + yield fout + fout.write("-- Ending log of %s at %s --\n" % (fname, datetime.now().isoformat(' '))) + def rm(tgt): if isdir(tgt): rmtree(tgt) |