Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework debug prints #1297

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions lua/pac3/core/server/util.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
local CurTime = CurTime
local math_Clamp = math.Clamp

function pac.dprint(fmt, ...)
if pac.debug then
MsgN("\n")
MsgN(">>>PAC3>>>")
MsgN(fmt:format(...))
if pac.debug_trace then
MsgN("==TRACE==")
debug.Trace()
MsgN("==TRACE==")
end
MsgN("<<<PAC3<<<")
MsgN("\n")
end
end


function pac.CallHook(str, ...)
return hook.Call("pac_" .. str, GAMEMODE, ...)
end
Expand Down
9 changes: 6 additions & 3 deletions lua/pac3/core/shared/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ local PREFIX_COLOR = Color(255, 255, 0)
local DEFAULT_TEXT_COLOR = Color(200, 200, 200)
local BOOLEAN_COLOR = Color(33, 83, 226)
local NUMBER_COLOR = Color(245, 199, 64)
local STEAMID_COLOR = Color(255, 255, 255)
local ENTITY_COLOR = Color(180, 232, 180)
local FUNCTION_COLOR = Color(62, 106, 255)
local TABLE_COLOR = Color(107, 200, 224)
Expand Down Expand Up @@ -97,12 +96,16 @@ function pac.Message(...)
return formatted
end

local debugLevel = CreateConVar("pac_debug", "0", FCVAR_ARCHIVE, "Debug mode for PAC3. 0 = off | 1 = debug | 2 = debug + trace", 0, 3)

function pac.dprint(fmt, ...)
if not pac.debug then return end
local debugInt = debugLevel:GetInt()
if debugInt == 0 then return end

MsgN("\n")
MsgN(">>>PAC3>>>")
MsgN(fmt:format(...))
if pac.debug_trace then
if debugInt == 2 then
MsgN("==TRACE==")
debug.Trace()
MsgN("==TRACE==")
Expand Down
16 changes: 0 additions & 16 deletions lua/pac3/editor/server/util.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
function pace.dprint(fmt, ...)
if pace.debug then
MsgN("\n")
MsgN(">>>PAC3>>>")
MsgN(fmt:format(...))
if pace.debug_trace then
MsgN("==TRACE==")
debug.Trace()
MsgN("==TRACE==")
end
MsgN("<<<PAC3<<<")
MsgN("\n")
end
end


function pace.CallHook(str, ...)
return hook.Call("pac_" .. str, GAMEMODE, ...)
end
Expand Down
6 changes: 3 additions & 3 deletions lua/pac3/editor/server/wear.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function pace.SubmitPart(data, filter)
if istable(data.part) then
if last_frame == frame_number then
table.insert(pace.StreamQueue, {data, filter})
pace.dprint("queuing part %q from %s", data.part.self.Name, tostring(data.owner))
pac.dprint("queuing part %q from %s", data.part.self.Name, tostring(data.owner))
return "queue"
end
end
Expand Down Expand Up @@ -299,7 +299,7 @@ function pace.SubmitPart(data, filter)
end

function pace.SubmitPartNotify(data)
pace.dprint("submitted outfit %q from %s with %i number of children to set on %s", data.part.self.Name or "", data.owner:GetName(), table.Count(data.part.children), data.part.self.OwnerName or "")
pac.dprint("submitted outfit %q from %s with %i number of children to set on %s", data.part.self.Name or "", data.owner:GetName(), table.Count(data.part.children), data.part.self.OwnerName or "")

local allowed, reason = pace.SubmitPart(data)

Expand All @@ -321,7 +321,7 @@ function pace.SubmitPartNotify(data)
end

function pace.RemovePart(data)
pace.dprint("%s is removed %q", data.owner and data.owner:IsValid() and data.owner:GetName(), data.part)
pac.dprint("%s is removed %q", data.owner and data.owner:IsValid() and data.owner:GetName(), data.part)

if data.part == "__ALL__" then
pace.CallHook("RemoveOutfit", data.owner)
Expand Down