Package: piuparts
Version: 0.38
Severity: wishlist
Tags: patch
User: [email protected]
Usertags: origin-ubuntu karmic ubuntu-patch

Hi,

The log generated by default of a local execution of piuparts (to test a 
package, for example) is very long and very complex to understand.
It would be useful to have an option that allow the end user to choose the level
of log he wants.

In my patch, I added a --log-level option, with 4 values: error, info, dump and 
debug. By default, the log level is still dump.
I also added an info message saying that the package has been successfully 
installed.

Hope it will be helpful.

Fabrice

*** /tmp/tmpbWfna7
In Ubuntu, we've applied the attached patch to achieve the following:

  * piuparts.py: added log-level option, to keep the log small. This option
    limits the output to info and error messages instead of default debug level.
    Also added an info message about successful installation of deb files.


-- System Information:
Debian Release: squeeze/sid
  APT prefers karmic-updates
  APT policy: (500, 'karmic-updates'), (500, 'karmic-security'), (500, 'karmic')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.31-17-generic (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash
diff -Nru piuparts-0.38ubuntu1/piuparts.py piuparts-0.38ubuntu2/piuparts.py
--- piuparts-0.38ubuntu1/piuparts.py	2010-01-07 08:15:04.000000000 +0100
+++ piuparts-0.38ubuntu2/piuparts.py	2010-01-27 21:25:46.000000000 +0100
@@ -793,6 +793,8 @@
                 self.run(["dpkg", "-i"] + tmp_files, ignore_errors=True)
                 self.run(["apt-get", "-yf", "--no-remove", "install"])
 
+            logging.info ("Installation of %s ok", tmp_files)
+
             if settings.scriptsdir is not None:
                 self.run_scripts("post_install")
 
@@ -1916,6 +1918,11 @@
                       default=False,
                       help="Warn only for broken symlinks.")
     
+    parser.add_option("--log-level", action="store",metavar='LEVEL',
+                      default="dump",
+                      help="Displays messages from LEVEL level. level values"
+                      " are: error, info, dump, debug")
+
     (opts, args) = parser.parse_args()
 
     settings.defaults = opts.defaults
@@ -1972,7 +1979,14 @@
                           settings.tmpdir)
             panic()
 
-    setup_logging(DUMP, log_file_name)
+    if opts.log_level == "error":
+        setup_logging(logging.ERROR, log_file_name)
+    elif opts.log_level == "info":
+        setup_logging(logging.INFO, log_file_name)
+    elif opts.log_level == "debug":
+        setup_logging(logging.DEBUG, log_file_name)
+    else:
+        setup_logging(DUMP, log_file_name)
 
     exit = None
 

Reply via email to