from __future__ import print_function, division
import sys
import time
from threading import Lock
from botlib.Config import Config

printLock = Lock()
logFile = Config.log.logfile and open(Config.log.logfile, 'a')

def info(fmt, *args, **kwargs):
	log('INFO', Config.log.log_info, Config.log.print_info, fmt.format(*args), **kwargs)

def error(fmt, *args, **kwargs):
	log('ERROR', Config.log.log_err, Config.log.print_err, fmt.format(*args), **kwargs)

def debug(fmt, *args, **kwargs):
	log('DEBUG', Config.log.log_debug, Config.log.print_debug, fmt.format(*args), **kwargs)

def reopen(path):
	global logFile
	if logFile:
		logFile.close()
	logFile = open(path, 'a')

def log(lvl, bLog, prtTarget, s, start='', end='\n'):
	s = '{}[{}][{}] {}{}'.format(start, time.strftime('%Y-%m-%d %H:%M:%S'), lvl, s, end)
	f = {'stdout': sys.stdout, 'stderr': sys.stderr}.get(prtTarget)
	printLock.acquire()
	try:
		if f:
			f.write(s)
			f.flush()
		if bLog and logFile:
			logFile.write(s)
			logFile.flush()
	finally:
		printLock.release()

@@ -204,24 +204,83 @@
 file, 'a')%0A%0A
+if Config.log.log_debug:%0A%09assert(Config.log.debug_lvl%3E=1)%0A%0A
 def info(fmt
@@ -513,37 +513,194 @@
 def 
+get_
 debug
-(fmt, *args, **kwargs):%0A
+_info():%0A%09if Config.log.log_debug:%0A%09%09return (True,Config.log.debug_lvl)%0A%0Adef debug(level ,fmt, *args, **kwargs):%0A%09assert(type(level) is int)%0A%09if level %3C= Config.log.debug_lvl:%0A%09
 %09log

Append Log.py features