aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mlog.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-07-05 23:23:49 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-07-06 06:25:12 +0000
commite4417eb301bab96c343c5b95f074d1900706b667 (patch)
treecde1f15ba6c58deacaf39f5e7d66476a1d14286a /mesonbuild/mlog.py
parent1415cd2d07477158bcc03a333a78522a3c972938 (diff)
downloadmeson-e4417eb301bab96c343c5b95f074d1900706b667.zip
meson-e4417eb301bab96c343c5b95f074d1900706b667.tar.gz
meson-e4417eb301bab96c343c5b95f074d1900706b667.tar.bz2
mlog: Log timestamps in profile-self mode
This makes it much clearer which statements are taking a long time, and helps in interpreting the outputted profile itself.
Diffstat (limited to 'mesonbuild/mlog.py')
-rw-r--r--mesonbuild/mlog.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index 3baa07a..b763e20 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -12,7 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import sys, os, platform, io
+import os
+import io
+import sys
+import time
+import platform
from contextlib import contextmanager
"""This is (mostly) a standalone module used to write logging
@@ -41,12 +45,17 @@ log_dir = None
log_file = None
log_fname = 'meson-log.txt'
log_depth = 0
+log_timestamp_start = None
def initialize(logdir):
global log_dir, log_file
log_dir = logdir
log_file = open(os.path.join(logdir, log_fname), 'w', encoding='utf8')
+def set_timestamp_start(start):
+ global log_timestamp_start
+ log_timestamp_start = start
+
def shutdown():
global log_file
if log_file is not None:
@@ -87,6 +96,8 @@ def cyan(text):
def process_markup(args, keep):
arr = []
+ if log_timestamp_start is not None:
+ arr = ['[{:.3f}]'.format(time.monotonic() - log_timestamp_start)]
for arg in args:
if isinstance(arg, str):
arr.append(arg)