Conversation
|
Review my humble PR 🥺 |
imaginarny
left a comment
There was a problem hiding this comment.
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()(andwarnnow as well) besides the manualdebug.error()as it might happen
| /** | ||
| * @group Debug | ||
| */ | ||
| export type DebugLog = { msg: string; time: number; style: DebugLogStyle }; |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
| * 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 |
There was a problem hiding this comment.
| * @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(" "); |
There was a problem hiding this comment.
| 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.
| const msg = message.concat().map((m) => m.toString()); | ||
| debug.logMessage(msg, "error"); |
There was a problem hiding this comment.
| 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.
| 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}]`; |
There was a problem hiding this comment.
| 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}]`;Co-authored-by: imaginarny <gencurpeter@gmail.com>
Co-authored-by: imaginarny <gencurpeter@gmail.com>
Please describe what issue(s) this PR fixes.
Summary