Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH] elog mod_echo: Print log path if PORT_LOGDIR is used
Date: Wed, 16 Aug 2017 10:11:12
Message-Id: 20170816101052.11225-1-mgorny@gentoo.org
1 Include the path to the log file if PORT_LOGDIR is being used
2 (and therefore the log is going to be preserved past the build). This is
3 useful when elog messages contain QA warnings or other errors that
4 require reporting a bug. In such case, having a path to the log is
5 handy.
6
7 After this commit, the mod_echo output becomes:
8
9 * Messages for package dev-foo/bar-1:
10 * Log file: /var/log/portage/dev-foo:bar-1:20170816-100533.log
11
12 * test
13 ---
14 pym/portage/elog/mod_echo.py | 13 ++++++++++---
15 1 file changed, 10 insertions(+), 3 deletions(-)
16
17 diff --git a/pym/portage/elog/mod_echo.py b/pym/portage/elog/mod_echo.py
18 index f9cc53788..bb34a1e44 100644
19 --- a/pym/portage/elog/mod_echo.py
20 +++ b/pym/portage/elog/mod_echo.py
21 @@ -1,5 +1,5 @@
22 # elog/mod_echo.py - elog dispatch module
23 -# Copyright 2007-2014 Gentoo Foundation
24 +# Copyright 2007-2017 Gentoo Foundation
25 # Distributed under the terms of the GNU General Public License v2
26
27 from __future__ import print_function
28 @@ -16,7 +16,12 @@ if sys.hexversion >= 0x3000000:
29 _items = []
30 def process(mysettings, key, logentries, fulltext):
31 global _items
32 - _items.append((mysettings["ROOT"], key, logentries))
33 + logfile = None
34 + # output logfile explicitly only if it isn't in tempdir, otherwise
35 + # it will be removed anyway
36 + if "PORT_LOGDIR" in mysettings:
37 + logfile = mysettings["PORTAGE_LOG_FILE"]
38 + _items.append((mysettings["ROOT"], key, logentries, logfile))
39
40 def finalize():
41 # For consistency, send all message types to stdout.
42 @@ -34,7 +39,7 @@ def finalize():
43 def _finalize():
44 global _items
45 printer = EOutput()
46 - for root, key, logentries in _items:
47 + for root, key, logentries, logfile in _items:
48 print()
49 if root == "/":
50 printer.einfo(_("Messages for package %s:") %
51 @@ -42,6 +47,8 @@ def _finalize():
52 else:
53 printer.einfo(_("Messages for package %(pkg)s merged to %(root)s:") %
54 {"pkg": colorize("INFORM", key), "root": root})
55 + if logfile is not None:
56 + printer.einfo(_("Log file: %s") % colorize("INFORM", logfile))
57 print()
58 for phase in EBUILD_PHASES:
59 if phase not in logentries:
60 --
61 2.14.1

Replies