Skip to content

Commit

Permalink
get date before yielding the event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Jan 5, 2025
1 parent fbfe012 commit 9adacd5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class JSONLogAttachment extends LogAttachment {
return Promise.resolve(serialize(m))
})

const date = new Date().toISOString()
Promise.all(messageParts)
.then(parts => {
return fetch(this.endpoint, {
Expand All @@ -104,7 +105,7 @@ export class JSONLogAttachment extends LogAttachment {
tags,
level: Object.entries(LogLevel).find(([k, v]) => v === level)[0],
message: parts.join(' '),
createdAt: new Date().toISOString()
createdAt: date
})
})
}).catch(e => console.error('Error in JSONLogAttachment', e))
Expand Down

0 comments on commit 9adacd5

Please sign in to comment.