Include the path to the log file if PORT_LOGDIR is being used
(and therefore the log is going to be preserved past the build). This is
useful when elog messages contain QA warnings or other errors that
require reporting a bug. In such case, having a path to the log is
handy.

After this commit, the mod_echo output becomes:

 * Messages for package dev-foo/bar-1:
 * Log file: /var/log/portage/dev-foo:bar-1:20170816-100533.log

 * test
---
 pym/portage/elog/mod_echo.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/pym/portage/elog/mod_echo.py b/pym/portage/elog/mod_echo.py
index f9cc53788..bb34a1e44 100644
--- a/pym/portage/elog/mod_echo.py
+++ b/pym/portage/elog/mod_echo.py
@@ -1,5 +1,5 @@
 # elog/mod_echo.py - elog dispatch module
-# Copyright 2007-2014 Gentoo Foundation
+# Copyright 2007-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
@@ -16,7 +16,12 @@ if sys.hexversion >= 0x3000000:
 _items = []
 def process(mysettings, key, logentries, fulltext):
        global _items
-       _items.append((mysettings["ROOT"], key, logentries))
+       logfile = None
+       # output logfile explicitly only if it isn't in tempdir, otherwise
+       # it will be removed anyway
+       if "PORT_LOGDIR" in mysettings:
+               logfile = mysettings["PORTAGE_LOG_FILE"]
+       _items.append((mysettings["ROOT"], key, logentries, logfile))
 
 def finalize():
        # For consistency, send all message types to stdout.
@@ -34,7 +39,7 @@ def finalize():
 def _finalize():
        global _items
        printer = EOutput()
-       for root, key, logentries in _items:
+       for root, key, logentries, logfile in _items:
                print()
                if root == "/":
                        printer.einfo(_("Messages for package %s:") %
@@ -42,6 +47,8 @@ def _finalize():
                else:
                        printer.einfo(_("Messages for package %(pkg)s merged to 
%(root)s:") %
                                {"pkg": colorize("INFORM", key), "root": root})
+               if logfile is not None:
+                       printer.einfo(_("Log file: %s") % colorize("INFORM", 
logfile))
                print()
                for phase in EBUILD_PHASES:
                        if phase not in logentries:
-- 
2.14.1


Reply via email to