fix(monitor): use global console channel and implement shard filtering
This commit is contained in:
+11
-3
@@ -29,8 +29,9 @@ export function isOfficialServer(hostname) {
|
||||
* @returns {string}
|
||||
*/
|
||||
export function buildSubscribePath(hostname, shard) {
|
||||
if (shard) return `${shard}/console`;
|
||||
return isOfficialServer(hostname) ? "shard0/console" : "console";
|
||||
// The console channel on Screeps official and most private servers is 'console'.
|
||||
// We subscribe to the aggregate feed and filter by shard in handleConsoleEvent.
|
||||
return "console";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,8 +179,15 @@ export async function uploadLogArtifact(
|
||||
* @param {{ sawTraceback: boolean, sawErrorLog: boolean, sawWarningLog: boolean }} state
|
||||
*/
|
||||
export function handleConsoleEvent(event, opts, stdoutBuffer, state) {
|
||||
const { logToFile } = opts;
|
||||
const { logToFile, shard: targetShard } = opts;
|
||||
const data = event?.data ?? {};
|
||||
|
||||
// Shard filtering: If a shard is specified in opts, only process messages from that shard.
|
||||
// Official server events include a 'shard' property in event.data.
|
||||
if (targetShard && data.shard && data.shard !== targetShard) {
|
||||
return;
|
||||
}
|
||||
|
||||
const logLines = data?.messages?.log ?? [];
|
||||
const results = data?.messages?.results ?? [];
|
||||
const errorText = data?.error ?? null;
|
||||
|
||||
Reference in New Issue
Block a user