17from logging
import handlers
23 """Debug settings for CLI
26 argDebug (bool): Debug Level
27 argLogFile (bool): CLI argument as logFile
28 fileName (str): Output name of log file
31 ValueError: If selected invalid log level
34 if argDebug
and (
not argLogFile):
35 DEBUG_SELECTION = argDebug
36 numeric_level = getattr(logging, DEBUG_SELECTION.upper(),
None)
37 if not isinstance(numeric_level, int):
38 raise ValueError(
"Invalid log level: %s" % DEBUG_SELECTION)
39 logging.basicConfig(format =
"[%(levelname)s] %(message)s", level = DEBUG_SELECTION)
41 if argLogFile
and argDebug:
42 log = logging.getLogger(
"")
43 level = logging.getLevelName(argDebug)
45 format = logging.Formatter(
"[%(levelname)s] %(message)s")
47 ch = logging.StreamHandler(sys.stdout)
48 ch.setFormatter(format)
51 loggerFile =
"tableReader.log"
52 if os.path.isfile(loggerFile):
55 fh = handlers.RotatingFileHandler(loggerFile, maxBytes = (1048576 * 5), backupCount = 7, mode =
"w")
56 fh.setFormatter(format)