123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- @Time : 2024/10/15 15:13
- @File : config.py
- @Desc :
- """
- import logging
- import os
- from logging.handlers import TimedRotatingFileHandler, QueueListener,QueueHandler
- from multiprocessing import Queue
- FILE_PATH = os.path.join(os.path.dirname(__file__), "data")
- LOG_PATH = os.path.join(os.path.dirname(__file__), "log")
- def get_logger(file ="log"):
- logfile = os.path.join(LOG_PATH, file+".log")
- logger = logging.getLogger(logfile)
- logger.propagate = True
- logger.setLevel(logging.INFO)
- sh = logging.StreamHandler()
- formatter = logging.Formatter('%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s - %(message)s')
- sh.setFormatter(formatter)
- logger.addHandler(sh)
- if file:
- fh = TimedRotatingFileHandler(logfile, when="midnight", backupCount=10, encoding="utf-8")
- #fh = logging.FileHandler(logfile)
- fh.setFormatter(formatter)
- logger.addHandler(fh)
- logger.addHandler(sh)
- # log_queue=Queue(-1)
- # qh = QueueHandler(log_queue)
- # qh.setFormatter(formatter)
- # logger.addHandler(qh)
- # ql=QueueListener(log_queue, fh, sh, respect_handler_level=True)
- # ql.start()
- return logger
- START = 'start'
- END = 'done'
- HANGUP = 'hang'
- TRANSFER = 'transfer'
- CONTINUE = 'normal'
- EMPTY = 'empty'
- MAX_TIMES_ANSWER = '播放次数超限'
- FAQ = 'faq'
- PURSUE = 'pursue'
- UNK = 'others'
- GENERATED = 'generated'
- FIXED = 'fixed'
- MOUDLES = {
- "10001": {
- "faq": {
- "content": ["未知"],
- "speech_id": "mainContent",
- "speech_type": "mainType",
- "speech_interrupt": "mainInterrupt"
- }
- }
- }
- # 异常类型
- INTENT_ERROR = '意图分类服务异常'
-
- def main():
- logger = get_logger()
- logger.info("hello")
- print(FILE_PATH)
-
-
- if __name__ == "__main__":
- main()
|