Skip to content

Commit

Permalink
save log file default when --release specified
Browse files Browse the repository at this point in the history
Signed-off-by: Gui Chen <[email protected]>
  • Loading branch information
Gui Chen committed Jul 10, 2012
1 parent c76cc1a commit 7e3624f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
11 changes: 9 additions & 2 deletions mic/imager/baseimager.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ def __init__(self, createopts = None, pkgmgr = None):
if 'release' in createopts and createopts['release']:
self.name += '-' + createopts['release']

# pending FEA: save log by default for --release

if self.pack_to:
if '@NAME@' in self.pack_to:
self.pack_to = self.pack_to.replace('@NAME@', self.name)
Expand Down Expand Up @@ -1159,6 +1157,15 @@ def _rpath(fn):
wf.write(fr.read().replace("@BUILD_ID@", release))
outimages.append(new_kspath)

# save log file, logfile is only available in creator attrs
if hasattr(self, 'logfile') and not self.logfile:
log_path = _rpath(self.name + ".log")
# touch the log file, else outimages will filter it out
with open(log_path, 'w') as wf:
wf.write('')
msger.set_logfile(log_path)
outimages.append(_rpath(self.name + ".log"))

# rename iso and usbimg
for f in os.listdir(destdir):
if f.endswith(".iso"):
Expand Down
21 changes: 11 additions & 10 deletions mic/msger.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,17 @@ def _general_print(head, color, msg = None, stream = None, level = 'normal'):
errormsg = os.read(CATCHERR_BUFFILE_FD, size)
os.ftruncate(CATCHERR_BUFFILE_FD, 0)

if LOG_FILE_FP:
if errormsg:
LOG_CONTENT += errormsg

save_msg = msg.strip() if msg else None
if save_msg:
global HOST_TIMEZONE
timestr = time.strftime("[%m/%d %H:%M:%S] ",
time.gmtime(time.time() - HOST_TIMEZONE))
LOG_CONTENT += timestr + save_msg + '\n'
# append error msg to LOG
if errormsg:
LOG_CONTENT += errormsg

# append normal msg to LOG
save_msg = msg.strip() if msg else None
if save_msg:
global HOST_TIMEZONE
timestr = time.strftime("[%m/%d %H:%M:%S] ",
time.gmtime(time.time() - HOST_TIMEZONE))
LOG_CONTENT += timestr + save_msg + '\n'

if errormsg:
_color_print('', NO_COLOR, errormsg, stream, level)
Expand Down

0 comments on commit 7e3624f

Please sign in to comment.