# Encoding: utf-8
# Date: 2019/5/30
# Name: 仲玲
import logging
from commen.time_util import Time_Util
import os


class Log_Method():


	def get_logger(self):

		now = Time_Util().day_time()
		log_path = os.path.dirname(os.path.abspath("."))+"//log//"+now+".log"
		err_path = os.path.dirname(os.path.abspath("."))+"//log//"+now+"_error.log"

		logger = logging.getLogger()
		logger.setLevel(logging.DEBUG)

		fh1 = logging.FileHandler(log_path,encoding="utf-8")
		fh2 = logging.FileHandler(err_path,encoding="utf-8")
		ch = logging.StreamHandler()

		formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(pathname)s - %(lineno)d"+"行"+"%(message)s")
		fh1.setLevel(logging.INFO)
		fh2.setLevel(logging.ERROR)
		ch.setLevel(logging.WARNING)

		fh1.setFormatter(formatter)
		fh2.setFormatter(formatter)
		ch.setFormatter(formatter)

		logger.addHandler(fh1)
		logger.addHandler(fh2)
		logger.addHandler(ch)

		return logger

if __name__ == '__main__':

	logger = Log_Method().get_logger()
	print(logger.error("zhe "))










