Skip to content

Commit

Permalink
Fallback for when function name isn't in stack
Browse files Browse the repository at this point in the history
  • Loading branch information
wearrrrr committed Oct 15, 2024
1 parent 7bae982 commit ca427c8
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export default {
fmt += `${stack[i].getFunctionName()} -> ` + fmt;
}
}

fmt += stack[0].getFunctionName();
fmt += stack[0].getFunctionName() || "Anonymous";

return fmt;
};
Expand Down Expand Up @@ -52,20 +51,16 @@ export default {
}[severity];

fn(
`%c${fmt}%c ${message}`,
`
background-color: ${bg};
color: ${fg};
padding: ${padding}px;
font-weight: bold;
font-family: monospace;
font-size: 0.9em;
`,
`
${severity === "debug" ? "color: gray" : ""}
`,
...args
);
`%c${fmt}%c ${message}`,
`
background-color: ${bg};
color: ${fg};
padding: ${padding}px;
font-weight: bold;
font-family: monospace;
font-size: 0.9em;
`,
`${severity === "debug" ? "color: gray" : ""}`, ...args);
},
log: function (message: string, ...args: any[]) {
this.fmt("log", message, ...args);
Expand Down

0 comments on commit ca427c8

Please sign in to comment.