Skip to content

Commit

Permalink
feat: log as trace continuous streaming events
Browse files Browse the repository at this point in the history
  • Loading branch information
KatoakDR committed Jan 22, 2024
1 parent 11ce4e6 commit cc1d342
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions electron/main/game/game.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class GameParserImpl implements GameParser {
logger.debug('subscribing to game socket stream');
gameSocketStream.subscribe({
next: (socketData) => {
logger.debug('parsing game socket data', { socketData });
logger.trace('parsing game socket data', { socketData });
const lines = this.convertSocketDataToLines(socketData);
this.parseLines(lines);
},
Expand Down Expand Up @@ -213,10 +213,10 @@ export class GameParserImpl implements GameParser {
// Ensure we start fresh with each line.
this.gameText = '';

logger.debug('parsing line', { line });
logger.trace('parsing line', { line });

while (line.length > 0) {
logger.debug('remaining line fragment', { line });
logger.trace('remaining line fragment', { line });

/*
* TEXT
Expand All @@ -228,7 +228,7 @@ export class GameParserImpl implements GameParser {
});

if (textSliceResult.match) {
logger.debug('parsed text', { text: textSliceResult.match });
logger.trace('parsed text', { text: textSliceResult.match });
this.processText(textSliceResult.match);
line = textSliceResult.remaining;
continue;
Expand All @@ -251,7 +251,7 @@ export class GameParserImpl implements GameParser {

if (endTagNameSliceResult.match) {
const tagName = endTagNameSliceResult.match;
logger.debug('parsed end tag', { tagName });
logger.trace('parsed end tag', { tagName });
this.processTagEnd();
}

Expand Down Expand Up @@ -285,7 +285,7 @@ export class GameParserImpl implements GameParser {
attributes[name] = value;
});

logger.debug('parsed start tag', { tagName, attributes });
logger.trace('parsed start tag', { tagName, attributes });
this.processTagStart(tagName, attributes);

if (tag.endsWith('/>')) {
Expand All @@ -309,7 +309,7 @@ export class GameParserImpl implements GameParser {
protected processText(text: string): void {
const { id: tagId = '', name: tagName = '' } = this.getActiveTag() ?? {};

logger.debug('processing text', {
logger.trace('processing text', {
text,
tagId,
tagName,
Expand Down Expand Up @@ -397,7 +397,7 @@ export class GameParserImpl implements GameParser {
tagName: string,
attributes: Record<string, string>
): void {
logger.debug('processing tag start', { tagName, attributes });
logger.trace('processing tag start', { tagName, attributes });

this.activeTags.push({
id: attributes.id,
Expand Down Expand Up @@ -485,7 +485,7 @@ export class GameParserImpl implements GameParser {
protected processTagEnd(): void {
const { id: tagId = '', name: tagName = '' } = this.getActiveTag() ?? {};

logger.debug('processing tag end', {
logger.trace('processing tag end', {
tagId,
tagName,
gameText: this.gameText,
Expand Down Expand Up @@ -803,7 +803,7 @@ export class GameParserImpl implements GameParser {
}

protected emitGameEvent(gameEvent: GameEvent): void {
logger.debug('emitting game event', { gameEvent });
logger.trace('emitting game event', { gameEvent });
this.gameEventsSubject$.next(gameEvent);
}
}
4 changes: 2 additions & 2 deletions electron/main/game/game.socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ export class GameSocketImpl implements GameSocket {

let buffer: string = '';
socket.on('data', (data: Buffer): void => {
logger.debug('socket received fragment');
logger.trace('socket received fragment');
buffer += data.toString('utf8');
if (buffer.endsWith('\n')) {
const message = buffer;
logger.debug('socket received message', { message });
logger.trace('socket received message', { message });
if (!this.isConnected && message.startsWith('<mode id="GAME"/>')) {
onGameConnect();
}
Expand Down
2 changes: 1 addition & 1 deletion electron/main/ipc/ipc.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class IpcController {
logger.debug('subscribing to game service stream');
gameEvents$.subscribe({
next: (gameEvent) => {
logger.debug('game service stream event', { gameEvent });
logger.trace('game service stream event', { gameEvent });
this.dispatch('game:event', { gameEvent });
},
error: (error) => {
Expand Down

0 comments on commit cc1d342

Please sign in to comment.