* chore(deps): bump @sentry/node from 7.114.0 to 8.2.1 Bumps [@sentry/node](https://github.com/getsentry/sentry-javascript) from 7.114.0 to 8.2.1. - [Release notes](https://github.com/getsentry/sentry-javascript/releases) - [Changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-javascript/compare/7.114.0...8.2.1) --- updated-dependencies: - dependency-name: "@sentry/node" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * update imports --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: chris48s <git@chris-shaw.dev>
54 lines
1.0 KiB
JavaScript
54 lines
1.0 KiB
JavaScript
import * as Sentry from '@sentry/node'
|
|
|
|
const listeners = []
|
|
|
|
// Zero-pad a number in a string.
|
|
// eg. 4 becomes 04 but 17 stays 17.
|
|
function pad(string) {
|
|
string = String(string)
|
|
return string.length < 2 ? `0${string}` : string
|
|
}
|
|
|
|
// Compact date representation.
|
|
// eg. 0611093840 for June 11, 9:38:40 UTC.
|
|
function date() {
|
|
const date = new Date()
|
|
return (
|
|
pad(date.getUTCMonth() + 1) +
|
|
pad(date.getUTCDate()) +
|
|
pad(date.getUTCHours()) +
|
|
pad(date.getUTCMinutes()) +
|
|
pad(date.getUTCSeconds())
|
|
)
|
|
}
|
|
|
|
const log = (...msg) => {
|
|
const d = date()
|
|
listeners.forEach(f => f(d, ...msg))
|
|
console.log(d, ...msg)
|
|
}
|
|
|
|
const error = err => {
|
|
const d = date()
|
|
listeners.forEach(f => f(d, err))
|
|
Sentry.captureException(err)
|
|
console.error(d, err)
|
|
}
|
|
|
|
const addListener = func => listeners.push(func)
|
|
|
|
const removeListener = func => {
|
|
const index = listeners.indexOf(func)
|
|
if (index < 0) {
|
|
return
|
|
}
|
|
listeners.splice(index, 1)
|
|
}
|
|
|
|
export default {
|
|
log,
|
|
error,
|
|
addListener,
|
|
removeListener,
|
|
}
|