aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorPjotr Prins2016-06-18 06:24:01 +0000
committerPjotr Prins2016-06-18 06:24:14 +0000
commit540926af239735854084ec1cfe06a3bd4fed8977 (patch)
treed3ff2292b4666a4d88b9f6771cf2eab5edbd4dab /wqflask/utility
parent93e3878c8b97ecbf28630e4bb3733a29f4cf45aa (diff)
downloadgenenetwork2-540926af239735854084ec1cfe06a3bd4fed8977.tar.gz
Logger: introducing logging
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/logger.py8
-rw-r--r--wqflask/utility/tools.py15
2 files changed, 17 insertions, 6 deletions
diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py
new file mode 100644
index 00000000..85a64438
--- /dev/null
+++ b/wqflask/utility/logger.py
@@ -0,0 +1,8 @@
+# GeneNetwork logger
+#
+# The standard python logging module is very good. This logger adds a
+# few facilities on top of that. Main one being that it picks up
+# settings for log levels (global and by module) and (potentially)
+# offers some fine grained log levels for the standard levels.
+#
+# Global settings (defined in default_settings.py).
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index 6e9f6d4a..d43e2132 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -3,8 +3,12 @@
import os
import sys
+import logging
from wqflask import app
+logger = logging.getLogger(__name__ )
+logging.basicConfig(level=logging.INFO)
+
def get_setting(command_id,guess=None):
"""Resolve a setting from the environment or the global settings in
app.config, with valid_path is a function checking whether the
@@ -37,7 +41,7 @@ def get_setting(command_id,guess=None):
return None
# ---- Check whether environment exists
- # sys.stderr.write("Looking for "+command_id+"\n")
+ logger.debug("Looking for "+command_id+"\n")
command = value(os.environ.get(command_id))
if not command:
# ---- Check whether setting exists in app
@@ -46,7 +50,7 @@ def get_setting(command_id,guess=None):
command = value(guess)
if not command:
raise Exception(command_id+' setting unknown or faulty (update settings.py?).')
- sys.stderr.write("Set "+command_id+"="+str(command)+"\n")
+ logger.info("Set "+command_id+"="+str(command))
return command
def valid_bin(bin):
@@ -101,7 +105,7 @@ def locate(name, subdir=None):
if valid_path(base):
lookfor = base + "/" + name
if valid_file(lookfor):
- print("Found: file "+lookfor+"\n")
+ logger.info("Found: file "+lookfor+"\n")
return lookfor
else:
raise Exception("Can not locate "+lookfor)
@@ -121,9 +125,9 @@ def locate_ignore_error(name, subdir=None):
if valid_path(base):
lookfor = base + "/" + name
if valid_file(lookfor):
- print("Found: file "+name+"\n")
+ logger.debug("Found: file "+name+"\n")
return lookfor
- sys.stderr.write("WARNING: file "+name+" not found\n")
+ logger.info("WARNING: file "+name+" not found\n")
return None
def tempdir():
@@ -141,4 +145,3 @@ GEMMA_COMMAND = gemma_command()
PLINK_COMMAND = plink_command()
FLAT_FILES = flat_files()
TEMPDIR = tempdir()
-