Ensure log file gets closed.

pull/2215/head
Jussi Pakkanen 8 years ago
parent 50fb7d37ab
commit c2a5ac3981
  1. 6
      mesonbuild/mesonmain.py
  2. 4
      mesonbuild/mlog.py

@ -135,6 +135,12 @@ If you want to change option values, use the mesonconf tool instead.'''
def generate(self): def generate(self):
env = environment.Environment(self.source_dir, self.build_dir, self.meson_script_launcher, self.options, self.original_cmd_line_args) env = environment.Environment(self.source_dir, self.build_dir, self.meson_script_launcher, self.options, self.original_cmd_line_args)
mlog.initialize(env.get_log_dir()) mlog.initialize(env.get_log_dir())
try:
self._generate(env)
finally:
mlog.shutdown()
def _generate(self, env):
mlog.debug('Build started at', datetime.datetime.now().isoformat()) mlog.debug('Build started at', datetime.datetime.now().isoformat())
mlog.debug('Python binary:', sys.executable) mlog.debug('Python binary:', sys.executable)
mlog.debug('Python system:', platform.system()) mlog.debug('Python system:', platform.system())

@ -31,7 +31,9 @@ def initialize(logdir):
def shutdown(): def shutdown():
global log_file global log_file
if log_file is not None: if log_file is not None:
log_file.close() exception_around_goer = log_file
log_file = None
exception_around_goer.close()
class AnsiDecorator: class AnsiDecorator:
plain_code = "\033[0m" plain_code = "\033[0m"

Loading…
Cancel
Save