Skip to content

Commit

Permalink
Add game branch to error log CFC-76 (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
wrefgtzweve committed Aug 14, 2023
1 parent 3eaa2c5 commit d42cf93
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions moon/autorun/client/cfc_err_fwd.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hook.Add "InitPostEntity", "CFC_ErrForwarder_BranchInit", ->
net.Start "cfc_err_forwarder_clbranch"
net.WriteString BRANCH
net.SendToServer!
6 changes: 6 additions & 0 deletions moon/autorun/server/cfc_err_fwd.moon
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "luaerror"
require "reqwest"

util.AddNetworkString "cfc_err_forwarder_clbranch"

timerName = "CFC_ErrorForwarderQueue"
errorForwarder = include "cfc_err_forwarder/error_forwarder.lua"
discordBuilder = include "cfc_err_forwarder/discord_interface.lua"
Expand Down Expand Up @@ -58,4 +60,8 @@ hook.Add "LuaError", "CFC_ServerErrorForwarder", ErrorForwarder\receiveSVError
hook.Add "ClientLuaError", "CFC_ClientErrorForwarder", ErrorForwarder\receiveCLError
hook.Add "ShutDown", "CFC_ShutdownErrorForwarder", ErrorForwarder\forwardErrors

net.Receive "cfc_err_forwarder_clbranch", (_,ply) ->
if not ply.CFC_ErrorForwarder_CLBranch
ply.CFC_ErrorForwarder_CLBranch = net.ReadString!

logger\info "Loaded!"
5 changes: 5 additions & 0 deletions moon/cfc_err_forwarder/error_forwarder.moon
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ return class ErrorForwarder

local plyName
local plySteamID
local branch
if ply
plyName = ply\Nick!
plySteamID = ply\SteamID!
branch = ply.CFC_ErrorForwarder_CLBranch or "Not sure yet"
else
branch = BRANCH

newError = {
:count
Expand All @@ -106,6 +110,7 @@ return class ErrorForwarder
:ply
:plyName
:plySteamID
:branch
reportInterval: @config.groomInterval\GetInt!
}

Expand Down
7 changes: 6 additions & 1 deletion moon/cfc_err_forwarder/formatter/formatter.moon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ niceStack = include "nice_stack.lua"

import
bad, bold, getSourceText, code,
steamIDLink, truncate, timestamp
steamIDLink, truncate, timestamp,
gmodBranch
from include "text_helpers.lua"

nonil = (t) -> [v for v in *t when v ~= nil]
Expand Down Expand Up @@ -39,6 +40,10 @@ nonil = (t) -> [v for v in *t when v ~= nil]
return { name: "Player", value: bold "#{plyName} ( #{steamIDLink plySteamID} )" } if ply
return nil

with {:branch} = data
return { name: "Branch", value: bold "`#{gmodBranch branch}`", inline: true } if branch
return nil

{
name: "Count"
value: bold data.count
Expand Down
5 changes: 4 additions & 1 deletion moon/cfc_err_forwarder/formatter/text_helpers.moon
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ getSourceText = (data) ->

"#{sourceLink}\n#{sourceText}"

:bad, :bold, :code, :steamIDLink, :truncate, :timestamp, :getSourceText
gmodBranch = (branch) ->
branch == "unknown" and "main" or branch

:bad, :bold, :code, :steamIDLink, :truncate, :timestamp, :getSourceText, :gmodBranch

0 comments on commit d42cf93

Please sign in to comment.