diff --git a/OlivaDiceLogger/app.json b/OlivaDiceLogger/app.json index a1c2be4..2a25121 100644 --- a/OlivaDiceLogger/app.json +++ b/OlivaDiceLogger/app.json @@ -4,8 +4,8 @@ "namespace" : "OlivaDiceLogger", "message_mode" : "old_string", "info" : "本模块为OlivaDice的日志模块,提供了跑团日志记录器,它可以在跑团过程中对日志进行记录,并由结果生成跑团日志,与在线的跑团日志渲染器进行联动、或发送日志邮件。", - "version" : "3.0.9", - "svn" : 17, + "version" : "3.0.10", + "svn" : 18, "compatible_svn" : 101, "priority" : 20030, "support" : [ diff --git a/OlivaDiceLogger/data.py b/OlivaDiceLogger/data.py index 910e287..cab8093 100644 --- a/OlivaDiceLogger/data.py +++ b/OlivaDiceLogger/data.py @@ -15,8 +15,8 @@ ''' -OlivaDiceLogger_ver = '3.0.9' -OlivaDiceLogger_svn = 17 +OlivaDiceLogger_ver = '3.0.10' +OlivaDiceLogger_svn = 18 OlivaDiceLogger_ver_short = '%s(%s)' % (str(OlivaDiceLogger_ver), str(OlivaDiceLogger_svn)) dataPath = './plugin/data/OlivaDice/unity' diff --git a/OlivaDiceLogger/logger.py b/OlivaDiceLogger/logger.py index 60fc9c1..d629fd2 100644 --- a/OlivaDiceLogger/logger.py +++ b/OlivaDiceLogger/logger.py @@ -22,9 +22,12 @@ import json import os import traceback +import threading import requests as req from functools import wraps +gLoggerIOLockMap = {} + def init_logger(plugin_event, Proc): releaseDir('%s%s' % (OlivaDiceLogger.data.dataPath, OlivaDiceLogger.data.dataLogPath)) OlivaDiceCore.crossHook.dictHookFunc['msgHook'] = add_logger_func(OlivaDiceCore.crossHook.dictHookFunc['msgHook']) @@ -167,8 +170,13 @@ def loggerEntry(event, funcType, sender, dectData, message): dataPath = OlivaDiceLogger.data.dataPath dataLogPath = OlivaDiceLogger.data.dataLogPath dataLogFile = '%s%s/%s.olivadicelog' % (dataPath, dataLogPath, tmp_logName) + if dataLogFile not in gLoggerIOLockMap: + gLoggerIOLockMap[dataLogFile] = threading.Lock() + loggerIOLock = gLoggerIOLockMap[dataLogFile] + loggerIOLock.acquire() with open(dataLogFile, 'a+', encoding = 'utf-8') as dataLogFile_f: dataLogFile_f.write('%s\n' % log_str) + loggerIOLock.release() pass def releaseLogFile(logName): diff --git a/OlivaDiceLogger/msgCustom.py b/OlivaDiceLogger/msgCustom.py index c025e32..751f95f 100644 --- a/OlivaDiceLogger/msgCustom.py +++ b/OlivaDiceLogger/msgCustom.py @@ -28,8 +28,8 @@ 'strLoggerLogAlreadyOff': '没有正在进行的日志', 'strLoggerLogEnd': '停止记录日志', 'strLoggerLogAlreadyEnd': '没有正在进行的日志', - 'strLoggerLogSave': '日志[{tLogName}]已保存', - 'strLoggerLogUrl': '日志已上传,请在[{tLogUrl}]提取日志' + 'strLoggerLogSave': '日志[ {tLogName} ]已保存', + 'strLoggerLogUrl': '日志已上传,请在[ {tLogUrl} ]提取日志' } dictStrConst = {