Skip to content

Commit

Permalink
Merge pull request #1701 from demergent-labs/better_logs
Browse files Browse the repository at this point in the history
Better logs
  • Loading branch information
lastmjs authored Mar 18, 2024
2 parents b39b487 + 0413402 commit ca0eeaf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ globalThis._azleInsideCanister =
if (globalThis._azleInsideCanister) {
const log = (...args: any[]) => {
const jsonStringifiedArgs = args
.map((arg) => JSON.stringify(arg, jsonReplacer, 4))
.map((arg) => {
if (arg instanceof Error) {
return `${arg.name}: ${arg.message} at ${arg.stack}`;
} else {
return JSON.stringify(arg, jsonReplacer, 4);
}
})
.join(' ');

ic.print(jsonStringifiedArgs);
Expand Down

0 comments on commit ca0eeaf

Please sign in to comment.