Skip to content

Commit

Permalink
immediately create the logger, but only start logging after we can pi…
Browse files Browse the repository at this point in the history
…ng the coordinator
  • Loading branch information
Harrison Ford committed Jan 4, 2024
1 parent 06b4b3f commit a4b7b61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions plugin/logger.luau
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local module = {
queuedMessages = {},
timeSinceLastSend = 0,
messageSendRate = 0.1,
sendMessages = false,
serverId = "",
serverUrl = "",
heartbeatConnection = nil,
Expand Down Expand Up @@ -48,6 +49,9 @@ function module:flushMessages()
end

function module:heartbeat(dt: number)
if not self.sendMessages then
return
end
self.timeSinceLastSend = self.timeSinceLastSend + dt

if self.timeSinceLastSend >= self.messageSendRate then
Expand Down
4 changes: 2 additions & 2 deletions plugin/plugin.luau
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ function getEvents()
return events
end

waitForStart()

Logger:init(SERVER_ID, SERVER_URL)
waitForStart()
Logger.sendMessages = true

-- register with the external coordinator
HttpService:PostAsync(SERVER_URL .. "/start", HttpService:JSONEncode({
Expand Down

0 comments on commit a4b7b61

Please sign in to comment.