Skip to content

Comments

feat: more debug logs#1028

Draft
lajbel wants to merge 6 commits intomasterfrom
more-debug-logs
Draft

feat: more debug logs#1028
lajbel wants to merge 6 commits intomasterfrom
more-debug-logs

Conversation

@lajbel
Copy link
Member

@lajbel lajbel commented Jan 28, 2026

Please describe what issue(s) this PR fixes.

Summary

  • Changeloged

@lajbel lajbel requested a review from mflerackers January 28, 2026 11:45
@lajbel
Copy link
Member Author

lajbel commented Jan 28, 2026

Review my humble PR 🥺

@lajbel lajbel requested a review from imaginarny January 30, 2026 15:19
Copy link
Member

@imaginarny imaginarny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So besides grammar/typos the main requested changes are:

  • To support object printing instead of [object Object] again as it got broken
  • Reintroduce the support for the Error instances being red also in the regular debug.log() (and warn now as well) besides the manual debug.error() as it might happen

/**
* @group Debug
*/
export type DebugLog = { msg: string; time: number; style: DebugLogStyle };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type DebugLog = { msg: string; time: number; style: DebugLogStyle };
export type DebugLog = {
msg: DebugMessage;
time: number;
style: DebugLogStyle;
};

warn(...message: DebugMessage[]): void;
/**
* Log an error message to on screen debug log.
* Log a message with the error style (pink since kaboom) in the debugging screen.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Log a message with the error style (pink since kaboom) in the debugging screen.
* Log a message with the error style (pink since kaboom) to the on-screen debug log.

* Log an error message to on screen debug log.
* Log a message with the error style (pink since kaboom) in the debugging screen.
*
* @param message - THe message to log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param message - THe message to log
* @param message - The message to log

logMessage: (message, wrapStyle = "info") => {
const max = gopt.logMax ?? LOG_MAX;
const msg = msgs.length > 1 ? msgs.concat(" ").join(" ") : msgs[0];
const msg = message.join(" ");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const msg = message.join(" ");
const msg = message.length > 1
? message.concat(" ").join(" ")
: message[0];

This is still needed to print objects otherwise you are getting [object Object] as in your playtest. Also, you can still get eg. an instance of Error in log or warn as well.

Comment on lines +190 to +191
const msg = message.concat().map((m) => m.toString());
debug.logMessage(msg, "error");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const msg = message.concat().map((m) => m.toString());
debug.logMessage(msg, "error");
debug.logMessage(message, "error");

Concatenation not need here anymore as it was reintroduced in the debug.logMessage() itself to support stuff mentioned above.

Comment on lines 192 to +195
let str = "";
const style = log.msg instanceof Error ? "error" : "info";
str += `[time]${log.time.toFixed(2)}[/time]`;
str += " ";
str += `[${style}]${prettyDebug(log.msg)}[/${style}]`;
str += `[${log.style}]${prettyDebug(log.msg)}[/${log.style}]`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let str = "";
const style = log.msg instanceof Error ? "error" : "info";
str += `[time]${log.time.toFixed(2)}[/time]`;
str += " ";
str += `[${style}]${prettyDebug(log.msg)}[/${style}]`;
str += `[${log.style}]${prettyDebug(log.msg)}[/${log.style}]`;
let str = "";
const style = log.msg instanceof Error ? "error" : log.style;
str += `[time]${log.time.toFixed(2)}[/time]`;
str += " ";
str += `[${style}]${prettyDebug(log.msg)}[/${style}]`;

As mentioned, you can still get an instance of Error also in the log or warn debug logs, so this can be supported as before and turn red.

GitHub messes up suggestions that had removed lines so idk how it turns out, the changes should be:

let str = "";
+ const style = log.msg instanceof Error ? "error" : log.style;
str += `[time]${log.time.toFixed(2)}[/time]`;
str += " ";
- str += `[${log.style}]${prettyDebug(log.msg)}[/${log.style}]`;
+ str += `[${style}]${prettyDebug(log.msg)}[/${style}]`;

lajbel and others added 4 commits February 18, 2026 15:36
Co-authored-by: imaginarny <gencurpeter@gmail.com>
Co-authored-by: imaginarny <gencurpeter@gmail.com>
Co-authored-by: imaginarny <gencurpeter@gmail.com>
Co-authored-by: imaginarny <gencurpeter@gmail.com>
@lajbel lajbel self-assigned this Feb 18, 2026
@lajbel lajbel marked this pull request as draft February 18, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants