# Path: XulDebugTool/controller/ConsoleDeskController.py
# class ConsoleController(object):
# 
#     @classmethod
#     def windowPrintInfo(self, loggername, mode, msg):
#         windowStr = LogFormatTool.buildStandardTime() + " - " + loggername + " - " + mode + " - "
# 
#         print(windowStr, end=' ')
#         for text in msg:
#             print(self.getLogContent(self, text), end=' ')
#         print("<br />")
#         return
# 
#     def getLogContent(self, text):
#         if isinstance(text, str):
#             regexUrl = re.compile(r"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*,]|(?:%[0-9a-fA-F][0-9a-fA-F]))+",
#                                   re.IGNORECASE)
#             urls = regexUrl.findall(text)
#             for url in urls:
#                 preS = "<a href=\"" + url + "\">" + url + "</a>"
#                 text = text.replace(url, preS)
# 
#         return text
# 
# Path: XulDebugTool/utils/ConfigHelper.py
# class ConfigHelper(object):
#     LOGCATPATH = ""
# 
#     #以下是配置信息所对应的key
#     KEY_LOGCATPATH = 'logcatPath'
# 
#     @staticmethod
#     def initLogConfigPath():
#         ConfigHelper.LOGCATPATH = ConfigurationDB.getConfiguration(ConfigHelper.KEY_LOGCATPATH)
#         if len(ConfigHelper.LOGCATPATH)<=0:
#             ConfigHelper.LOGCATPATH = str(os.getcwd()) + "\logcat.txt"
#             ConfigurationDB.saveConfiguration(ConfigHelper.KEY_LOGCATPATH,ConfigHelper.LOGCATPATH)


import logging
from XulDebugTool.controller.ConsoleDeskController import ConsoleController
from XulDebugTool.utils.ConfigHelper import ConfigHelper
# coding: utf-8
"""
author: CAI
last edited: 2017.10.29
"""



class STCLogger():
    DEBUG = "debug"
    INFO = "info"
    WARNING = "warning"
    ERROR = "error"
    CRITICAL = "critical"
    def __init__(self):

        self.loggername = "STCLogger"
        #当前日志模式
        self.setLogLevel(self.INFO)

        #logging.basicConfig(level=logging.DEBUG)
        self.logger = logging.getLogger(self.loggername)

        self.logger.setLevel(logging.DEBUG)

        # create a file handler

# Path: XulDebugTool/controller/ConsoleDeskController.py
# class ConsoleController(object):
# 
#     @classmethod
#     def windowPrintInfo(self, loggername, mode, msg):
#         windowStr = LogFormatTool.buildStandardTime() + " - " + loggername + " - " + mode + " - "
# 
#         print(windowStr, end=' ')
#         for text in msg:
#             print(self.getLogContent(self, text), end=' ')
#         print("<br />")
#         return
# 
#     def getLogContent(self, text):
#         if isinstance(text, str):
#             regexUrl = re.compile(r"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*,]|(?:%[0-9a-fA-F][0-9a-fA-F]))+",
#                                   re.IGNORECASE)
#             urls = regexUrl.findall(text)
#             for url in urls:
#                 preS = "<a href=\"" + url + "\">" + url + "</a>"
#                 text = text.replace(url, preS)
# 
#         return text
# 
# Path: XulDebugTool/utils/ConfigHelper.py
# class ConfigHelper(object):
#     LOGCATPATH = ""
# 
#     #以下是配置信息所对应的key
#     KEY_LOGCATPATH = 'logcatPath'
# 
#     @staticmethod
#     def initLogConfigPath():
#         ConfigHelper.LOGCATPATH = ConfigurationDB.getConfiguration(ConfigHelper.KEY_LOGCATPATH)
#         if len(ConfigHelper.LOGCATPATH)<=0:
#             ConfigHelper.LOGCATPATH = str(os.getcwd()) + "\logcat.txt"
#             ConfigurationDB.saveConfiguration(ConfigHelper.KEY_LOGCATPATH,ConfigHelper.LOGCATPATH)


# Path: XulDebugTool/logcatapi/Logcat.py
import logging
from XulDebugTool.controller.ConsoleDeskController import ConsoleController
from XulDebugTool.utils.ConfigHelper import ConfigHelper

# coding: utf-8
"""
author: CAI
last edited: 2017.10.29
"""



class STCLogger():
    DEBUG = "debug"
    INFO = "info"
    WARNING = "warning"
    ERROR = "error"
    CRITICAL = "critical"
    def __init__(self):

        self.loggername = "STCLogger"
        #当前日志模式
        self.setLogLevel(self.INFO)

        #logging.basicConfig(level=logging.DEBUG)
        self.logger = logging.getLogger(self.loggername)

        self.logger.setLevel(logging.DEBUG)

        # create a file handler

        self.handler = logging.FileHandler(ConfigHelper.LOGCATPATH, "a", encoding="UTF-8")