Skip to content

Commit

Permalink
3.0.10,优化默认文本,优化日志记录的线程安全性
Browse files Browse the repository at this point in the history
close #1
  • Loading branch information
MetaLe0 committed Jul 27, 2024
1 parent 4b3dbd7 commit 09f42a0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions OlivaDiceLogger/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" : [
Expand Down
4 changes: 2 additions & 2 deletions OlivaDiceLogger/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 8 additions & 0 deletions OlivaDiceLogger/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions OlivaDiceLogger/msgCustom.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
'strLoggerLogAlreadyOff': '没有正在进行的日志',
'strLoggerLogEnd': '停止记录日志',
'strLoggerLogAlreadyEnd': '没有正在进行的日志',
'strLoggerLogSave': '日志[{tLogName}]已保存',
'strLoggerLogUrl': '日志已上传,请在[{tLogUrl}]提取日志'
'strLoggerLogSave': '日志[ {tLogName} ]已保存',
'strLoggerLogUrl': '日志已上传,请在[ {tLogUrl} ]提取日志'
}

dictStrConst = {
Expand Down

0 comments on commit 09f42a0

Please sign in to comment.