summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2013-07-12 08:56:00 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-07-12 11:43:12 +0100
commit3c57a9b8a41b0b1244e649f0766f45d54012f395 (patch)
tree47cb422a7d839c9c9c9179ebfd6a97e82f6a553a
parent479bba2cdcda8dbd86861ea62c8c25bfef633148 (diff)
Resolves: #i120083# make python loglevel and log output changeable...
through environment vars Set the log level with the environment variable "PYSCRIPT_LOG_LEVEL" "DEBUG" (for debugging) "ERROR" (show errors only) "NONE" (or anything else) (for production) is the default and the log output type with the enviroment variable "PYSCRIPT_LOG_STDOUT" "0" (log output to user/Scripts/python/log.txt) "1" (or anything else) (log output to stdout) Patch by: Tsutomu Uchino <hanya.runo@gmail.com> Review by: Herbert Durr <hdu@apache.org> Note: Commit message edited by ASF infra team to work around a known issue with the ASF svn install (not an issue with svn) and UTF-8 handling. This is a temporary issue that we hope to resolve soon. (cherry picked from commit 9dc7f72febe9d294304f70cc7b9cdeab1c67dc8b) Change-Id: I099c8b3f812559c380078f63b692c83fdc811e33
-rwxr-xr-xscripting/source/pyprov/pythonscript.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/scripting/source/pyprov/pythonscript.py b/scripting/source/pyprov/pythonscript.py
index 789b6a6c1d1a..d2e90ba1a5c1 100755
--- a/scripting/source/pyprov/pythonscript.py
+++ b/scripting/source/pyprov/pythonscript.py
@@ -31,16 +31,24 @@ except NameError:
unicode = str
class LogLevel:
- NONE = 0
- ERROR = 1
- DEBUG = 2
+ NONE = 0 # production level
+ ERROR = 1 # for script developers
+ DEBUG = 2 # for script framework developers
+
+PYSCRIPT_LOG_ENV = "PYSCRIPT_LOG_LEVEL"
+PYSCRIPT_LOG_STDOUT_ENV = "PYSCRIPT_LOG_STDOUT"
# Configuration ----------------------------------------------------
-LogLevel.use = LogLevel.NONE # production level
-#LogLevel.use = LogLevel.ERROR # for script developers
-#LogLevel.use = LogLevel.DEBUG # for script framework developers
-LOG_STDOUT = True # True, writes to stdout (difficult on windows)
- # False, writes to user/Scripts/python/log.txt
+LogLevel.use = LogLevel.NONE
+if os.environ.get(PYSCRIPT_LOG_ENV) == "ERROR":
+ LogLevel.use = LogLevel.ERROR
+elif os.environ.get(PYSCRIPT_LOG_ENV) == "DEBUG":
+ LogLevel.use = LogLevel.DEBUG
+
+# True, writes to stdout (difficult on windows)
+# False, writes to user/Scripts/python/log.txt
+LOG_STDOUT = os.environ.get(PYSCRIPT_LOG_STDOUT_ENV, "1") != "0"
+
ENABLE_EDIT_DIALOG=False # offers a minimal editor for editing.
#-------------------------------------------------------------------