Add a dev settings feature, keyed off codename right now

This commit is contained in:
Lucien Greathouse
2018-12-03 16:54:21 -08:00
parent 061ea0e7a3
commit 503d7400f3
7 changed files with 86 additions and 37 deletions

View File

@@ -1,5 +1,6 @@
local DevSettings = require(script.Parent.DevSettings)
local testLogLevel = nil
local configValue = game:FindFirstChild("ROJO_LOG")
local Level = {
Error = 0,
@@ -17,32 +18,37 @@ local function getLogLevel()
return _G.ROJO_LOG
end
if configValue ~= nil then
return configValue.Value
local hyperValue = DevSettings:getLogLevel()
if hyperValue ~= nil then
return hyperValue
end
return Level.Info
end
local function addTags(tag, message)
return tag .. message:gsub("\n", "\n" .. tag)
end
local Log = {}
Log.Level = Level
function Log.trace(template, ...)
if getLogLevel() >= Level.Trace then
print("[Rojo-Trace] " .. string.format(template, ...))
print(addTags("[Rojo-Trace] ", string.format(template, ...)))
end
end
function Log.info(template, ...)
if getLogLevel() >= Level.Info then
print("[Rojo-Info] " .. string.format(template, ...))
print(addTags("[Rojo-Info] ", string.format(template, ...)))
end
end
function Log.warn(template, ...)
if getLogLevel() >= Level.Warning then
warn("[Rojo-Warn] " .. string.format(template, ...))
warn(addTags("[Rojo-Warn] ", string.format(template, ...)))
end
end