[Getan-commits] [PATCH 3 of 5] Logging can be activated and deactivated

Wald Commits scm-commit at wald.intevation.org
Thu Jun 28 16:29:45 CEST 2018


# HG changeset patch
# User Magnus Schieder <mschieder at intevation.de>
# Date 1530180076 -7200
# Node ID d47e32e6b7e79e7443e7267de0569b08f1d8093b
# Parent  999a438474f26d8e2568d82d4e98c36f7761e981
Logging can be activated and deactivated.

diff -r 999a438474f2 -r d47e32e6b7e7 CHANGES
--- a/CHANGES	Wed Jun 27 11:54:56 2018 +0200
+++ b/CHANGES	Thu Jun 28 12:01:16 2018 +0200
@@ -1,10 +1,13 @@
 2.x 20xx-xx-xx UNRELEASED
 
+ * The logging can now be switched on and off. The default value is off.
+   If logging is off, no log file is created.
+   More information can be found in ./doc/old_issues.txt -20170504 BER
+
  * Add a redraw function on key Control-L.
    The screen is completely redrawn. More information can be found in
    ./doc/old_issues.txt -20180321 BER
 
-
  * Better fix for the multiple selection bug.
    The multiple selection is deleted when deleting or moving is confirmed or
    when switching to projects.
diff -r 999a438474f2 -r d47e32e6b7e7 TODO
--- a/TODO	Wed Jun 27 11:54:56 2018 +0200
+++ b/TODO	Thu Jun 28 12:01:16 2018 +0200
@@ -23,9 +23,6 @@
 20170709 BER: Give scripts/getan-eval.py a more specific name and add
   it as a script to be installed.
 
-20170504 BER: Some multi-user installations do not want a logfile by default.
-  We could solve this requirement by making it configurable.
-
 20160912 BER: Better code: states.py: classes EditEntryState and
   AdjustEntryState have same methods exit() and set_focus(), maybe join them?
 
diff -r 999a438474f2 -r d47e32e6b7e7 doc/old_issues.txt
--- a/doc/old_issues.txt	Wed Jun 27 11:54:56 2018 +0200
+++ b/doc/old_issues.txt	Thu Jun 28 12:01:16 2018 +0200
@@ -1,3 +1,6 @@
+20170504 BER: Some multi-user installations do not want a logfile by default.
+  We could solve this requirement by making it configurable.
+
 20180321 BER Add a redraw function/key, usually Control-L is used.
     If the screen gets disorted, e.g. by a background process spilling
     some stuff on stderror, you want a completely redrawn screen without
diff -r 999a438474f2 -r d47e32e6b7e7 getan/config.py
--- a/getan/config.py	Wed Jun 27 11:54:56 2018 +0200
+++ b/getan/config.py	Thu Jun 28 12:01:16 2018 +0200
@@ -25,10 +25,14 @@
 
 def setup_logging(level, filename):
     global logger
-    logging.basicConfig(level=level,
-                        format='%(asctime)s %(levelname)s %(message)s',
-                        filename=filename,
-                        filemode='w')
+    if level is logging.NOTSET:
+        logging.NullHandler()
+    else:
+        logging.basicConfig(level=level,
+                            format='%(asctime)s %(levelname)s %(message)s',
+                            filename=filename,
+                            filemode='w')
+
     logger = logging.getLogger()
 
 
diff -r 999a438474f2 -r d47e32e6b7e7 getan/main.py
--- a/getan/main.py	Wed Jun 27 11:54:56 2018 +0200
+++ b/getan/main.py	Thu Jun 28 12:01:16 2018 +0200
@@ -53,8 +53,8 @@
     parser.add_argument('--init-only', action='store_true', dest='initonly',
                         help='create databasefile if necessary and exit')
     parser.add_argument('-d', '--debug', action='store_const', dest='loglevel',
-                        default=logging.INFO, const=logging.DEBUG,
-                        help='set verbosity to debug')
+                        default=logging.NOTSET, const=logging.DEBUG,
+                        help='Enable debung mode')
     parser.add_argument('-l', '--logfile', dest='logfile', metavar='FILE',
                         help='''write log information to FILE [default:
                         %(default)s]''', default='getan.log')


More information about the Getan-commits mailing list