Skip to content

Commit 06bd074

Browse files
author
zach
authored
fix: improve conversion of Errors in console functions (#133)
1 parent 94d0e17 commit 06bd074

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ members = [
66
]
77

88
[workspace.package]
9-
version = "1.5.0"
9+
version = "1.5.1"
1010
edition = "2021"
1111
authors = ["The Extism Authors"]
1212
license = "BSD-Clause-3"

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,15 @@ module.exports = { count };
253253

254254
### Logging
255255

256-
At the current time, calling `console.log` emits an `info` log. Please file an
257-
issue or PR if you want to expose the raw logging interface:
256+
There are several functions that can be used for logging:
258257

259258
```javascript
260259
function logStuff() {
261-
console.log("Hello, World!");
260+
console.info("Info");
261+
console.debug("Debug");
262+
console.error("Error");
263+
console.warn("Warning");
264+
console.log("Log"); // Alias for console.info
262265
}
263266

264267
module.exports = { logStuff };

crates/core/src/prelude/src/console.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function stringifyArg(arg: any): string {
2424

2525
if (typeof arg === 'object') {
2626
if (arg instanceof Error) {
27-
return arg.stack || `${arg.name}: ${arg.message}`;
27+
return `${arg.name}: ${arg.message}${arg.stack ? '\n' : ''}${arg.stack}`;
2828
}
2929
if (arg instanceof Set) {
3030
return `Set(${arg.size}) { ${Array.from(arg).map(String).join(', ')} }`;
@@ -71,4 +71,4 @@ const console = {
7171

7272
globalThis.console = console;
7373

74-
export { };
74+
export { };

0 commit comments

Comments
 (0)