[PATCH] elog mod_echo: Print log path if PORT_LOGDIR is used

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] elog mod_echo: Print log path if PORT_LOGDIR is used

Michał Górny-5
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 | Threaded
Open this post in threaded view
|

Re: [PATCH] elog mod_echo: Print log path if PORT_LOGDIR is used

Brian Dolbec-3
On Wed, 16 Aug 2017 12:10:52 +0200
Michał Górny <[hidden email]> wrote:

> 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:


Looks good to me :)

--
Brian Dolbec <dolsen>


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] elog mod_echo: Print log path if PORT_LOGDIR is used

Michał Górny-5
W dniu śro, 16.08.2017 o godzinie 09∶12 -0700, użytkownik Brian Dolbec
napisał:

> On Wed, 16 Aug 2017 12:10:52 +0200
> Michał Górny <[hidden email]> wrote:
>
> > 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:
>
>
> Looks good to me :)
>

Merged.

--
Best regards,
Michał Górny