diff --git a/lua/autorun/gmod_integration.lua b/lua/autorun/gmod_integration.lua index b1daaaf..dba6882 100644 --- a/lua/autorun/gmod_integration.lua +++ b/lua/autorun/gmod_integration.lua @@ -2,13 +2,23 @@ if game.SinglePlayer() then return print("Gmod Integration is not supported in S gmInte = gmInte || {} gmInte.version = "0.5.0" gmInte.config = {} +gmInte.useDataConfig = true +function gmInte.simpleLog(msg, debug) + print(" | " .. os.date(gmInte.config.logTimestamp || "%Y-%m-%d %H:%M:%S") .. " | Gmod Integration | " .. msg) +end + local function loadConfig() RunConsoleCommand("sv_hibernate_think", "1") if !file.Exists("gm_integration", "DATA") || !file.Exists("gm_integration/config.json", "DATA") then file.CreateDir("gm_integration") file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true)) else - if gmInte.config.id && gmInte.config.id != "" then return end + if gmInte.config.id && gmInte.config.id != "" then + gmInte.useDataConfig = false + timer.Simple(1, function() gmInte.simpleLog("Using Data Config | This is not recommended, please revert change and use ig cmd !gmi to edit your config", true) end) + return + end + local oldConfig = util.JSONToTable(file.Read("gm_integration/config.json", "DATA")) if !oldConfig.version || (oldConfig.version < gmInte.version) then table.Merge(gmInte.config, oldConfig) @@ -17,6 +27,8 @@ local function loadConfig() else gmInte.config = oldConfig end + + gmInte.simpleLog("Using Data Config | Data config loaded from data/gm_integration/config.json") end end @@ -25,7 +37,6 @@ local function loadFile(folder, fileName) local path = folder .. "/" .. fileName if loadedFiles[path] then return end loadedFiles[path] = true - print(" | Loading File | " .. path) if string.StartWith(fileName, "cl_") then if SERVER then AddCSLuaFile(path) @@ -40,6 +51,7 @@ local function loadFile(folder, fileName) end if fileName == "sv_config.lua" then loadConfig() end + gmInte.simpleLog("File Loaded | " .. path) end local function loadFolder(folder) diff --git a/lua/gmod_integration/core/config/cl_admin_menu.lua b/lua/gmod_integration/core/config/cl_admin_menu.lua index fdb0d62..ab4ae5b 100644 --- a/lua/gmod_integration/core/config/cl_admin_menu.lua +++ b/lua/gmod_integration/core/config/cl_admin_menu.lua @@ -222,6 +222,21 @@ function gmInte.openConfigMenu(data) ["onEditDelay"] = 0.5, ["category"] = gmInte.getTranslation("admin.advanced", "Advanced") }, + { + ["id"] = "logTimestamp", + ["label"] = gmInte.getTranslation("admin.internal_log_format", "Internal Log Format"), + ["description"] = gmInte.getTranslation("admin.internal_log_format_description", "The timestamp format of the logs."), + ["type"] = "textEntry", + ["resetIfEmpty"] = true, + ["defaultValue"] = "%Y-%m-%d %H:%M:%S", + ["value"] = function(setting, value) return value end, + ["onEdit"] = function(setting, value) + if !value || value == "" then return end + saveConfig(setting, value) + end, + ["onEditDelay"] = 0.5, + ["category"] = gmInte.getTranslation("admin.advanced", "Advanced") + }, } local buttonsInfo = { diff --git a/lua/gmod_integration/core/config/sv_settings.lua b/lua/gmod_integration/core/config/sv_settings.lua index 5279d37..5e9bafe 100644 --- a/lua/gmod_integration/core/config/sv_settings.lua +++ b/lua/gmod_integration/core/config/sv_settings.lua @@ -58,7 +58,8 @@ function gmInte.publicGetConfig(ply) ["websocketFQDN"] = gmInte.config.websocketFQDN, ["adminRank"] = gmInte.config.adminRank, ["language"] = gmInte.config.language, - ["clientBranch"] = gmInte.config.clientBranch + ["clientBranch"] = gmInte.config.clientBranch, + ["logTimestamp"] = gmInte.config.logTimestamp }, ["other"] = { ["aprovedCredentials"] = gmInte.aprovedCredentials, diff --git a/lua/gmod_integration/core/utils/sh_utils.lua b/lua/gmod_integration/core/utils/sh_utils.lua index 4b735d4..962b89a 100644 --- a/lua/gmod_integration/core/utils/sh_utils.lua +++ b/lua/gmod_integration/core/utils/sh_utils.lua @@ -1,29 +1,29 @@ local function getTimeStamp() if !gmInte.config.debug then return "" end - return os.date("[%Y-%m-%d %H:%M:%S]") + return os.date(gmInte.config.logTimestamp || "%Y-%m-%d %H:%M:%S") end function gmInte.log(msg, debug) if debug && !gmInte.config.debug then return end - print(getTimeStamp() .. " [Gmod Integration] " .. msg) + print(getTimeStamp() .. " | Gmod Integration | " .. msg) end // Log Error function gmInte.logError(msg, debug) if debug && !gmInte.config.debug then return end - print(getTimeStamp() .. " [Gmod Integration] [ERROR] " .. msg) + print(getTimeStamp() .. " | Gmod Integration | ERROR | " .. msg) end // Log Warning function gmInte.logWarning(msg, debug) if debug && !gmInte.config.debug then return end - print(getTimeStamp() .. " [Gmod Integration] [WARNING] " .. msg) + print(getTimeStamp() .. " | Gmod Integration | WARNING | " .. msg) end // Log Hint function gmInte.logHint(msg, debug) if debug && !gmInte.config.debug then return end - print(getTimeStamp() .. " [Gmod Integration] [HINT] " .. msg) + print(getTimeStamp() .. " | Gmod Integration | HINT | " .. msg) end // Is Private IP diff --git a/lua/gmod_integration/sv_config.lua b/lua/gmod_integration/sv_config.lua index b4b06ab..0818e11 100644 --- a/lua/gmod_integration/sv_config.lua +++ b/lua/gmod_integration/sv_config.lua @@ -38,6 +38,7 @@ gmInte.config.clientBranch = "any" // The branch of the addon that the clients s gmInte.config.supportLink = "" // The link of your support (shown when a player do not have the requiments to join the server) gmInte.config.maintenance = false // If true, the addon will only allow the players with the "gmod-integration.maintenance" permission to join the server gmInte.config.language = "en" // The language of the addon (en, fr, de, es, it, tr, ru) +gmInte.config.logTimestamp = "%H:%M:%S" // The timestamp format of the logs gmInte.config.adminRank = { // How can edit the configuration of the addon / bypass the maintenance mode ["superadmin"] = true,