Skip to content

Commit

Permalink
Rev. B34
Browse files Browse the repository at this point in the history
  • Loading branch information
hoontee committed Sep 12, 2023
1 parent 3789fa9 commit ce64792
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 36 deletions.
22 changes: 15 additions & 7 deletions Pronghorn/Debug/init.lua → Pronghorn/Debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local Debug = {}
-- Helper Variables
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

local ENABLED_CHANNELS = require(script.EnabledChannels) :: {[string]: boolean}
local enabledChannels: {[string]: boolean} = {}

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Module Functions
Expand All @@ -24,9 +24,9 @@ local ENABLED_CHANNELS = require(script.EnabledChannels) :: {[string]: boolean}
function Debug.Print(...: any?)
local channel = tostring(getfenv(2).script)

if ENABLED_CHANNELS[channel] == nil then error(`'{channel}' is not a valid debug channel`) end
if enabledChannels[channel] == nil then error(`'{channel}' is not a valid debug channel`) end

if ENABLED_CHANNELS[channel] then
if enabledChannels[channel] then
print(`[{channel}]`, ...)
end
end
Expand All @@ -37,9 +37,9 @@ end
function Debug.Warn(...: any?)
local channel = tostring(getfenv(2).script)

if ENABLED_CHANNELS[channel] == nil then error(`'{channel}' is not a valid debug channel`) end
if enabledChannels[channel] == nil then error(`'{channel}' is not a valid debug channel`) end

if ENABLED_CHANNELS[channel] then
if enabledChannels[channel] then
warn(`[{channel}]`, ...)
end
end
Expand All @@ -50,13 +50,21 @@ end
function Debug.Trace(...: any?)
local channel = tostring(getfenv(2).script)

if ENABLED_CHANNELS[channel] == nil then error(`'{channel}' is not a valid debug channel`) end
if enabledChannels[channel] == nil then error(`'{channel}' is not a valid debug channel`) end

if ENABLED_CHANNELS[channel] then
if enabledChannels[channel] then
warn(`[{channel}] {table.concat({...}, " ")}\n{debug.traceback()}`)
end
end

--- Sets the list of enabled channels.
--- @param newEnabledChannels -- The list of enabled channels.
function Debug:SetEnabledChannels(newEnabledChannels: {[string]: boolean})
if type(newEnabledChannels) ~= "table" then error(`Debug.SetEnabledChannels: Parameter 'newEnabledChannels' expected type '\{[string]: boolean}', got {typeof(newEnabledChannels)}`, 0) end

enabledChannels = newEnabledChannels
end

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

return Debug
17 changes: 0 additions & 17 deletions Pronghorn/Debug/EnabledChannels.lua

This file was deleted.

2 changes: 1 addition & 1 deletion Pronghorn/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
║ ██████▀██▓▌▀▌ ▄ ▄▓▌▐▓█▌ ║
║ ║
║ ║
║ Pronghorn Framework Rev. B33
║ Pronghorn Framework Rev. B34
║ https://github.com/Iron-Stag-Games/Pronghorn ║
║ GNU Lesser General Public License v2.1 ║
║ ║
Expand Down
13 changes: 2 additions & 11 deletions sourcemap.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,9 @@
"name": "Debug",
"className": "ModuleScript",
"filePaths": [
"Pronghorn/Debug/init.lua"
"Pronghorn/Debug.lua"
],
"children": [
{
"name": "EnabledChannels",
"className": "ModuleScript",
"filePaths": [
"Pronghorn/Debug/EnabledChannels.lua"
],
"children": []
}
]
"children": []
},
{
"name": "Remotes",
Expand Down

0 comments on commit ce64792

Please sign in to comment.