SF.net SVN: gar:[23106] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Mar 2 18:52:13 CET 2014


Revision: 23106
          http://sourceforge.net/p/gar/code/23106
Author:   wahwah
Date:     2014-03-02 17:52:11 +0000 (Sun, 02 Mar 2014)
Log Message:
-----------
pkgdb: Nicer format for logging messager

h/t Carsten Grzemba

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/checkpkg2.py
    csw/mgar/gar/v2/lib/python/csw_upload_pkg.py
    csw/mgar/gar/v2/lib/python/integrate_catalogs.py
    csw/mgar/gar/v2/lib/python/pkgdb.py
    csw/mgar/gar/v2/lib/python/safe_remove_package.py

Modified: csw/mgar/gar/v2/lib/python/checkpkg2.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg2.py	2014-03-02 16:22:34 UTC (rev 23105)
+++ csw/mgar/gar/v2/lib/python/checkpkg2.py	2014-03-02 17:52:11 UTC (rev 23106)
@@ -116,7 +116,8 @@
   elif options.debug:
     # If both flags are set, debug wins.
     logging_level = logging.DEBUG
-  logging.basicConfig(level=logging_level)
+  fmt = '%(levelname)s %(asctime)s %(filename)s:%(lineno)d %(message)s'
+  logging.basicConfig(format=fmt, level=logging_level)
   logging.debug("Starting.")
 
   configuration.SetUpSqlobjectConnection()

Modified: csw/mgar/gar/v2/lib/python/csw_upload_pkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/csw_upload_pkg.py	2014-03-02 16:22:34 UTC (rev 23105)
+++ csw/mgar/gar/v2/lib/python/csw_upload_pkg.py	2014-03-02 17:52:11 UTC (rev 23106)
@@ -402,10 +402,11 @@
             "Note that the server side only allows to upload to a limited "
             "set of catalogs."))
   options, args = parser.parse_args()
+  logging_level = logging.INFO
   if options.debug:
-    logging.basicConfig(level=logging.DEBUG)
-  else:
-    logging.basicConfig(level=logging.INFO)
+    logging_level = logging.DEBUG)
+  fmt = '%(levelname)s %(asctime)s %(filename)s:%(lineno)d %(message)s'
+  logging.basicConfig(format=fmt, level=logging_level)
   logging.debug("args: %s", args)
   hostname = socket.gethostname()
   if not hostname.startswith('login'):

Modified: csw/mgar/gar/v2/lib/python/integrate_catalogs.py
===================================================================
--- csw/mgar/gar/v2/lib/python/integrate_catalogs.py	2014-03-02 16:22:34 UTC (rev 23105)
+++ csw/mgar/gar/v2/lib/python/integrate_catalogs.py	2014-03-02 17:52:11 UTC (rev 23106)
@@ -271,10 +271,12 @@
   parser.add_option("--debug", dest="debug",
                     default=False, action="store_true")
   options, args = parser.parse_args()
-  loglevel = logging.INFO
+  logging_level = logging.INFO
   if options.debug:
-    loglevel = logging.DEBUG
-  logging.basicConfig(level=loglevel)
+    logging_level = logging.DEBUG
+  fmt = '%(levelname)s %(asctime)s %(filename)s:%(lineno)d %(message)s'
+  logging.basicConfig(format=fmt, level=logging_level)
+
   if not options.output_file:
     raise UsageError("Please specify the output file.  See --help.")
   catrel_from = options.catrel_from

Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py	2014-03-02 16:22:34 UTC (rev 23105)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py	2014-03-02 17:52:11 UTC (rev 23106)
@@ -412,11 +412,13 @@
                     default=False, action="store_true",
                     help="Force unpacking of packages")
   options, args = parser.parse_args()
+
+  logging_level = logging.INFO
   if options.debug:
-    logging.basicConfig(level=logging.DEBUG)
-    logging.debug("Debugging on")
-  else:
-    logging.basicConfig(level=logging.INFO)
+    logging_level = logging.DEBUG)
+  fmt = '%(levelname)s %(asctime)s %(filename)s:%(lineno)d %(message)s'
+  logging.basicConfig(format=fmt, level=logging_level)
+
   if not args:
     raise UsageError("Please specify a command.  See --help.")
   # SetUpSqlobjectConnection needs to be called after

Modified: csw/mgar/gar/v2/lib/python/safe_remove_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/safe_remove_package.py	2014-03-02 16:22:34 UTC (rev 23105)
+++ csw/mgar/gar/v2/lib/python/safe_remove_package.py	2014-03-02 17:52:11 UTC (rev 23106)
@@ -204,10 +204,11 @@
                     default=False, action="store_true",
                     help=("Don't apply changes (no REST calls)."))
   options, args = parser.parse_args()
-  debug_level = logging.INFO
+  logging_level = logging.INFO
   if options.debug:
-    debug_level = logging.DEBUG
-  logging.basicConfig(level=debug_level)
+    logging_level = logging.DEBUG
+  fmt = '%(levelname)s %(asctime)s %(filename)s:%(lineno)d %(message)s'
+  logging.basicConfig(format=fmt, level=logging_level)
   if not options.catalogname:
     logging.error('option catalogname required \n%s',USAGE)
     sys.exit(1)

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list