/
This commit is contained in:
@@ -58,9 +58,14 @@ function PLUGIN:LoadPersistentLogs()
|
||||
local line = lines[i]
|
||||
if not line or line == "" or string.StartWith(line, "===") then continue end
|
||||
|
||||
-- Пример лога: [10:38:40][Боевые действия] Игрок умер
|
||||
-- Нам нужно распарсить это обратно в таблицу
|
||||
local timeStr, categoryName, msg = string.match(line, "%[(%d%d:%d%d:%d%d)%]%[(.-)%] (.*)")
|
||||
-- Пробуем новый формат: [Время][Категория][SteamID] Сообщение
|
||||
local timeStr, categoryName, steamid, msg = string.match(line, "^%[(%d%d:%d%d:%d%d)%]%[(.-)%]%[(STEAM_%d:%d:%d+)%] (.*)")
|
||||
|
||||
-- Если не вышло, пробуем старый формат: [Время][Категория] Сообщение
|
||||
if not timeStr then
|
||||
timeStr, categoryName, msg = string.match(line, "^%[(%d%d:%d%d:%d%d)%]%[(.-)%] (.*)")
|
||||
steamid = "N/A"
|
||||
end
|
||||
|
||||
if timeStr and categoryName and msg then
|
||||
-- Находим ID категории по имени
|
||||
@@ -74,10 +79,14 @@ function PLUGIN:LoadPersistentLogs()
|
||||
|
||||
table.insert(logsToLoad, {
|
||||
id = #logsToLoad + 1,
|
||||
type = "LOADED", -- Специальный тип для загруженных
|
||||
type = "LOADED",
|
||||
category = categoryID,
|
||||
message = "[АРХИВ] " .. msg,
|
||||
timestamp = 0, -- Мы не знаем точную дату, только время
|
||||
target = {
|
||||
name = steamid ~= "N/A" and steamid or "Архив",
|
||||
steamid = steamid
|
||||
},
|
||||
timestamp = 0,
|
||||
timeString = timeStr,
|
||||
isPersistent = true
|
||||
})
|
||||
@@ -106,8 +115,8 @@ function PLUGIN:AddLog(logType, message, target, data)
|
||||
category = self.LOG_TYPES[logType].category,
|
||||
message = message,
|
||||
target = target and {
|
||||
name = IsValid(target) and target:Nick() or tostring(target),
|
||||
steamid = IsValid(target) and target:SteamID() or "N/A"
|
||||
name = IsValid(target) and target:Nick() or (isstring(target) and target or tostring(target)),
|
||||
steamid = IsValid(target) and target:SteamID() or (isstring(target) and string.match(target, "STEAM_%d:%d:%d+") and target or "N/A")
|
||||
} or nil,
|
||||
data = data or {},
|
||||
timestamp = os.time(),
|
||||
@@ -124,9 +133,11 @@ function PLUGIN:AddLog(logType, message, target, data)
|
||||
|
||||
-- Сохраняем в файл
|
||||
if self.logFile then
|
||||
local logString = string.format("[%s][%s] %s\n",
|
||||
local targetSID = (logEntry.target and logEntry.target.steamid ~= "N/A") and ("[" .. logEntry.target.steamid .. "]") or ""
|
||||
local logString = string.format("[%s][%s]%s %s\n",
|
||||
logEntry.timeString,
|
||||
self.LOG_CATEGORIES[logEntry.category].name,
|
||||
targetSID,
|
||||
message
|
||||
)
|
||||
file.Append(self.logFile, logString)
|
||||
|
||||
Reference in New Issue
Block a user