logging日志

彩色日志+日志初始化

自己的库:crifanLogging.py

已实现常用的功能,包括:

  • 彩色日志
  • 初始化

使用方式 = 典型调用代码:

先下载我的库:

对于文件:somePythonFile.py

调用和初始化代码:

import crifanLogging

CurFilePath = os.path.abspath(__file__)
# print("CurFilePath=%s" % CurFilePath)
CurFilename = os.path.basename(CurFilePath)
# 'autoSearchGame_YingYongBao.py'
CurFileNoSuffix, pointSuffix = os.path.splitext(CurFilename)

CurFolder = os.path.dirname(CurFilePath)
# print("CurFolder=%s" % CurFolder)

LogFolder = os.path.join(CurFolder, "logs")

def initLog():
    curDatetimeStr = utils.getCurDatetimeStr() # '20200316_155954'
    utils.createFolder(LogFolder)
    curLogFile = "%s_%s.log" % (CurFileNoSuffix, curDatetimeStr)
    logFullPath = os.path.join(LogFolder, curLogFile)
    crifanLogging.loggingInit(logFullPath)

def main():
    initLog()

即可生成log文件:logs/somePythonFile.log

注:相关函数:

results matching ""

    No results matching ""