Skip to content

Commit 23a20f4

Browse files
committed
style(api): update log tags from BALATROBOT to API
Standardize logging tags to use "API" prefix for better organization and consistency across the API module.
1 parent b205aae commit 23a20f4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/lua/api.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function API.update(_)
2525
API.socket:settimeout(SOCKET_TIMEOUT)
2626
local port = BALATRO_BOT_CONFIG.port
2727
API.socket:setsockname("127.0.0.1", tonumber(port) or 12346)
28-
sendDebugMessage("UDP socket created on port " .. port, "BALATROBOT")
28+
sendDebugMessage("UDP socket created on port " .. port, "API")
2929
end
3030

3131
-- Process pending requests
@@ -56,16 +56,16 @@ function API.update(_)
5656
local func = API.functions[data.name]
5757
local args = data.arguments
5858
if func == nil then
59-
API.send_error_response("Unknown function name", { function_name = data.name })
59+
API.send_error_response("Unknown function name", { name = data.name })
6060
elseif type(args) ~= "table" then
6161
API.send_error_response("Arguments must be a table", { received_type = type(args) })
6262
else
63-
sendDebugMessage(data.name .. "(" .. json.encode(args) .. ")", "BALATROBOT")
63+
sendDebugMessage(data.name .. "(" .. json.encode(args) .. ")", "API")
6464
func(args)
6565
end
6666
end
6767
elseif client_ip ~= "timeout" then
68-
sendErrorMessage("UDP error: " .. tostring(client_ip), "BALATROBOT")
68+
sendErrorMessage("UDP error: " .. tostring(client_ip), "API")
6969
end
7070
end
7171

@@ -81,7 +81,7 @@ end
8181
---@param message string The error message
8282
---@param context? table Optional additional context about the error
8383
function API.send_error_response(message, context)
84-
sendErrorMessage(message, "BALATROBOT")
84+
sendErrorMessage(message, "API")
8585
local response = { error = message, state = G.STATE }
8686
if context then
8787
response.context = context
@@ -106,7 +106,7 @@ function API.init()
106106
G.FPS_CAP = 60
107107
end
108108

109-
sendInfoMessage("BalatrobotAPI initialized", "BALATROBOT")
109+
sendInfoMessage("BalatrobotAPI initialized", "API")
110110
end
111111

112112
--------------------------------------------------------------------------------
@@ -125,7 +125,7 @@ end
125125
---@param _ table Arguments (not used)
126126
API.functions["go_to_menu"] = function(_)
127127
if G.STATE == G.STATES.MENU and G.MAIN_MENU_UI then
128-
sendDebugMessage("go_to_menu called but already in menu", "BALATROBOT")
128+
sendDebugMessage("go_to_menu called but already in menu", "API")
129129
local game_state = utils.get_game_state()
130130
API.send_response(game_state)
131131
return
@@ -155,7 +155,7 @@ API.functions["start_run"] = function(args)
155155
local deck_found = false
156156
for _, v in pairs(G.P_CENTER_POOLS.Back) do
157157
if v.name == args.deck then
158-
sendDebugMessage("Changing to deck: " .. v.name, "BALATROBOT")
158+
sendDebugMessage("Changing to deck: " .. v.name, "API")
159159
G.GAME.selected_back:change_to(v)
160160
G.GAME.viewed_back:change_to(v)
161161
deck_found = true

0 commit comments

Comments
 (0)