when run mic with options '--logfile=dir', traceback shows
msger.set_loglevel('debug')
if self.options.logfile:
+ logfile_abs_path = abspath(self.options.logfile)
+ if not os.path.exists(os.path.dirname(logfile_abs_path)):
+ os.makedirs(os.path.dirname(logfile_abs_path))
+ if os.path.isdir(logfile_abs_path):
+ raise errors.Usage("logfile's path %s should be file"
+ % self.options.logfile)
msger.set_interactive(False)
- msger.set_logfile(self.options.logfile)
+ msger.set_logfile(logfile_abs_path)
configmgr.create['logfile'] = self.options.logfile
if self.options.config:
def _savelogf():
if LOG_FILE_FP:
- if not os.path.exists(os.path.dirname(LOG_FILE_FP)):
- os.makedirs(os.path.dirname(LOG_FILE_FP))
fp = open(LOG_FILE_FP, 'w')
fp.write(LOG_CONTENT)
fp.close()
if LOG_FILE_FP is not None:
warning('duplicate log file configuration')
- LOG_FILE_FP = os.path.abspath(os.path.expanduser(fpath))
+ LOG_FILE_FP = fpath
import atexit
atexit.register(_savelogf)