Skip to content

Commit

Permalink
feat(logger): accepting Error objects as parameters in io.logger.erro…
Browse files Browse the repository at this point in the history
…r() (#797)

* feat(logger): accepting Error objects as parameters in io.logger.error()

* Allow errors for any log level

* Create silent-ties-vanish.md

---------

Co-authored-by: Matt Aitken <[email protected]>
  • Loading branch information
Abhi1992002 and matt-aitken authored Jan 15, 2024
1 parent 1dcee2b commit ff4ff86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-ties-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---

You can pass an Error() instead of properties to all of the `io.logger` functions
8 changes: 8 additions & 0 deletions packages/trigger-sdk/src/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ export class IO {
return new IOLogger(async (level, message, data) => {
let logLevel: LogLevel = "info";

if(data instanceof Error){
data = {
name : data.name,
message : data.message,
stack : data.stack
}
}

if (Logger.satisfiesLogLevel(logLevel, this._jobLogLevel)) {
await this.runTask(
[message, level],
Expand Down

0 comments on commit ff4ff86

Please sign in to comment.