Commit 18225e5e authored by Gerald Salin's avatar Gerald Salin
Browse files

#48 : be able to set the log level

parent 57bce8af
......@@ -30,7 +30,9 @@ log_directory = os.path.dirname(jflowconf.get_log_file_path())
if not os.path.isdir(log_directory):
os.makedirs(log_directory, 0o751)
logging.basicConfig(level=logging.DEBUG,
#log_level = eval(jflowconf.get_log_level())
#if (log_level = logging.DEBUG
logging.basicConfig(level=eval(jflowconf.get_log_level()),
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename=jflowconf.get_log_file_path(),
......
......@@ -72,7 +72,16 @@ class JFlowConfigReader(object):
return self.reader.get('storage', 'log_file').replace("###USER###",os.getenv("USER"))
except :
raise NoOptionError("Failed when parsing the config file, no section logging found!")
def get_log_level(self):
"""
return the level of log
@return: the level of logging (logging.DEBUG, logging.WARNING....
"""
try:
return self.reader.get('storage', 'log_level')
except :
raise Error("Failed when parsing the config file !")
def get_makeflow_path(self):
try:
......
......@@ -29,7 +29,7 @@ log_directory = os.path.dirname(ng6conf.get_log_file_path())
if not os.path.isdir(log_directory):
os.makedirs(log_directory, 0o751)
logging.basicConfig(level=logging.DEBUG,
logging.basicConfig(level=eval(ng6conf.get_log_level()),
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename=ng6conf.get_log_file_path(),
......
......@@ -25,7 +25,7 @@ __status__ = 'beta'
import os
from configparser import ConfigParser
from .utils import *
import logging
class NG6ConfigReader(object):
"""
Class NG6ConfigReader: this object read the config file and return the different configuration values
......@@ -40,7 +40,8 @@ class NG6ConfigReader(object):
Build a ConfigReader
"""
self.reader = ConfigParser()
self.reader.read(self.CONFIG_FILE)
self.reader.read(self.CONFIG_FILE)
logging.getLogger("jflow").debug("NG6ConfigReader.__init__, fichier de config charge = " + self.CONFIG_FILE)
def get_typo3_db_params(self):
......@@ -109,6 +110,15 @@ class NG6ConfigReader(object):
return self.reader.get('storage', 'log_file')
except :
raise Error("Failed when parsing the config file !")
def get_log_level(self):
"""
return the level of log
@return: the level of logging (logging.DEBUG, logging.WARNING....
"""
try:
return self.reader.get('storage', 'log_level')
except :
raise Error("Failed when parsing the config file !")
def get_454_mids(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment