aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/snippets/altered-logging.md5
-rw-r--r--mesonbuild/dependencies/boost.py2
-rw-r--r--mesonbuild/mconf.py5
-rw-r--r--mesonbuild/mesonmain.py14
-rw-r--r--mesonbuild/mlog.py29
-rw-r--r--mesonbuild/rewriter.py6
6 files changed, 37 insertions, 24 deletions
diff --git a/docs/markdown/snippets/altered-logging.md b/docs/markdown/snippets/altered-logging.md
new file mode 100644
index 0000000..4ff9bb0
--- /dev/null
+++ b/docs/markdown/snippets/altered-logging.md
@@ -0,0 +1,5 @@
+## Log output slightly changed
+
+The format of some human-readable diagnostic messages has changed in
+minor ways. In case you are parsing these messages, you may need to
+adjust your code.
diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py
index 03cc7b8..a17fb58 100644
--- a/mesonbuild/dependencies/boost.py
+++ b/mesonbuild/dependencies/boost.py
@@ -167,7 +167,7 @@ class BoostDependency(ExternalDependency):
invalid_modules = [x for x in invalid_modules if x not in remove]
if invalid_modules:
- mlog.log(mlog.red('ERROR:'), 'Invalid Boost modules: ' + ', '.join(invalid_modules))
+ mlog.error('Invalid Boost modules: ' + ', '.join(invalid_modules))
return True
else:
return False
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py
index db109b7..b409615 100644
--- a/mesonbuild/mconf.py
+++ b/mesonbuild/mconf.py
@@ -249,9 +249,8 @@ def run(args):
if save:
c.save()
except ConfException as e:
- print('Meson configurator encountered an error:\n')
- print(e)
- return 1
+ print('Meson configurator encountered an error:')
+ raise e
return 0
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index 69b4e31..9c4498c 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -304,7 +304,7 @@ def run(original_args, mainfile=None):
try:
return mconf.run(remaining_args)
except MesonException as e:
- mlog.log(mlog.red('\nError configuring project:'), e)
+ mlog.exception(e)
sys.exit(1)
elif cmd_name == 'wrap':
return wraptool.run(remaining_args)
@@ -324,8 +324,8 @@ def run(original_args, mainfile=None):
try:
sys.exit(run_script_command(args[1:]))
except MesonException as e:
- mlog.log(mlog.red('\nError in {} helper script:'.format(script)))
- mlog.log(e)
+ mlog.error('\nError in {} helper script:'.format(script))
+ mlog.exception(e)
sys.exit(1)
args = args[2:]
handshake = True
@@ -368,13 +368,7 @@ def run(original_args, mainfile=None):
app.generate()
except Exception as e:
if isinstance(e, MesonException):
- mlog.log()
- if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(e, 'colno'):
- mlog.log('%s:%d:%d:' % (e.file, e.lineno, e.colno), mlog.red('ERROR: '), end='')
- else:
- mlog.log(mlog.red('ERROR: '), end='')
- # Error message
- mlog.log(e)
+ mlog.exception(e)
# Path to log file
mlog.shutdown()
logfile = os.path.join(app.build_dir, environment.Environment.log_dir, mlog.log_fname)
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index 3c34b85..347cede 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -102,19 +102,38 @@ def log(*args, **kwargs):
arr = process_markup(args, True)
force_print(*arr, **kwargs)
-def warning(*args, **kwargs):
+def _log_error(severity, *args, **kwargs):
from . import environment
-
- args = (yellow('WARNING:'),) + args
+ if severity == 'warning':
+ args = (yellow('WARNING:'),) + args
+ elif severity == 'error':
+ args = (red('ERROR:'),) + args
+ else:
+ assert False, 'Invalid severity ' + severity
if 'location' in kwargs:
location = kwargs['location']
del kwargs['location']
- location = '{}:{}:'.format(os.path.join(location.subdir, environment.build_filename), location.lineno)
- args = (location,) + args
+ location_str = '{}:{}:'.format(os.path.join(location.subdir,
+ environment.build_filename),
+ location.lineno)
+ args = (location_str,) + args
log(*args, **kwargs)
+def error(*args, **kwargs):
+ return _log_error('error', *args, **kwargs)
+
+def warning(*args, **kwargs):
+ return _log_error('warning', *args, **kwargs)
+
+def exception(e):
+ log()
+ if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(e, 'colno'):
+ log('%s:%d:%d:' % (e.file, e.lineno, e.colno), red('ERROR: '), e)
+ else:
+ log(red('ERROR:'), e)
+
# Format a list for logging purposes as a string. It separates
# all but the last item with commas, and the last with 'and'.
def format_list(list):
diff --git a/mesonbuild/rewriter.py b/mesonbuild/rewriter.py
index 0191c30..fad7ba0 100644
--- a/mesonbuild/rewriter.py
+++ b/mesonbuild/rewriter.py
@@ -54,11 +54,7 @@ def run(args):
sys.exit('Unknown command: ' + options.commands[0])
except Exception as e:
if isinstance(e, MesonException):
- if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(e, 'colno'):
- mlog.log(mlog.red('\nMeson encountered an error in file %s, line %d, column %d:' % (e.file, e.lineno, e.colno)))
- else:
- mlog.log(mlog.red('\nMeson encountered an error:'))
- mlog.log(e)
+ mlog.exception(e)
else:
traceback.print_exc()
return 1