【发布时间】:2017-09-29 00:34:14
【问题描述】:
执行从 Robot Framework 中进行,其中 Test.py 已作为库导入,testLog() 正在执行,然后导入 Logger.py 并调用 LogMessage()。
Test.py
import Logger
def testLog():
Logger.LogMessage("This is the first line of the log file.")
Logger.LogMessage("This is the second line of the log file.")
Logger.LogMessage("This is the third line of the log file.")
记录器.py
import logging
def LogMessage(message):
LOG_FILENAME = "C://Log_Details".log"
logger = logging.getLogger()
logFileHandler = logging.FileHandler(LOG_FILENAME)
logger.addHandler(logFileHandler)
Log_Details.log
This is the first line of the log file.
This is the second line of the log file.
This is the second line of the log file.
This is the third line of the log file.
This is the third line of the log file.
This is the third line of the log file.
RIDE 中的消息日志部分在执行期间只记录每行一次,但名为 Log_details.log 的文件会多次打印它们,即第一行记录一次,第二行记录两次,依此类推。
【问题讨论】:
标签: python logging robotframework robotframework-ide