[elbe-devel] [PATCH v4 16/41] Add logging to opt.output for command adjustpkgs

Torben Hohn torben.hohn at linutronix.de
Wed Aug 7 12:03:30 CEST 2019


On Mon, Jul 08, 2019 at 05:18:12PM +0200, dion at linutronix.de wrote:
> From: Olivier Dion <dion at linutronix.de>
> 
> make use of the new logging system, and replace all print() with
> functions from logging and wrap it in
> "with elbe_logging({"files":opt.output}):"
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/commands/adjustpkgs.py | 28 +++++++++++++---------------
>  1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/elbepack/commands/adjustpkgs.py b/elbepack/commands/adjustpkgs.py
> index f7dbdd0b..e1551ef8 100644
> --- a/elbepack/commands/adjustpkgs.py
> +++ b/elbepack/commands/adjustpkgs.py
> @@ -6,25 +6,21 @@
>  
>  from __future__ import print_function
>  
> +import logging
> +import os
>  import sys
>  from optparse import OptionParser
>  
>  import apt
>  import apt.progress
>  
> -from elbepack.asciidoclog import ASCIIDocLog
>  from elbepack.treeutils import etree
> +from elbepack.log import elbe_logging
>  
>  
>  class adjpkg(object):
> -    def __init__(self, logfile, name):
> -
> -        self.outf = ASCIIDocLog(logfile)
> -
> -        if name:
> -            self.outf.h1("ELBE Report for Project " + name)
> -        else:
> -            self.outf.h1("ELBE Report")
> +    def __init__(self, name):
> +        logging.info("ELBE Report for Project %s", name)
>  
>      def set_pkgs(self, pkglist):
>  
> @@ -45,20 +41,20 @@ class adjpkg(object):
>                     p.installed.priority == "important" or \
>                     p.installed.priority == "required":
>                      continue
> -                print("MARK REMOVE %s" % p.name)
> +                logging.info("MARK REMOVE %s", p.name)
>                  p.mark_delete(auto_fix=False, purge=True)
>  
>              for name in pkglist:
>  
>                  if name not in cache:
> -                    self.outf.printo("- package %s does not exist" % name)
> +                    logging.warning('Package "%s" does not exist' % name)
>                      errors += 1
>                      continue
>  
>                  cp = cache[name]
>  
>                  cp.mark_install()
> -                print("MARK INSTALL %s" % cp.name)
> +                logging.info("MARK INSTALL %s", cp.name)
>  
>              cache.commit(apt.progress.base.AcquireProgress(),
>                           apt.progress.base.InstallProgress())
> @@ -71,7 +67,7 @@ class adjpkg(object):
>                      continue
>                  if p.is_auto_removable:
>                      p.mark_delete(purge=True)
> -                    print("MARKED AS AUTOREMOVE %s" % p.name)
> +                    logging.info("MARKED AS AUTOREMOVE %s", p.name)
>  
>          cache.commit(apt.progress.base.AcquireProgress(),
>                       apt.progress.base.InstallProgress())
> @@ -114,8 +110,10 @@ def run_command(argv):
>          buildenv_pkgs = [p.et.text for p in xml.node(
>              "project/buildimage/pkg-list")]
>  
> -    adj = adjpkg(opt.output, opt.name)
> -    return adj.set_pkgs(xml_pkgs + mandatory_pkgs + buildenv_pkgs)
> +
> +    with elbe_logging({"files":opt.output}):
> +        adj = adjpkg(opt.name)
> +        return adj.set_pkgs(xml_pkgs + mandatory_pkgs + buildenv_pkgs)
>  
>  
>  if __name__ == "__main__":
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list