From 540926af239735854084ec1cfe06a3bd4fed8977 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 18 Jun 2016 06:24:01 +0000 Subject: Logger: introducing logging --- wqflask/utility/tools.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'wqflask/utility/tools.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() - -- cgit v1.2.3