Skip to content

Commit

Permalink
[Updater] Replace unmaintained winston-sentry-log with `winston-tra…
Browse files Browse the repository at this point in the history
…nsport-sentry-node`
  • Loading branch information
valtterikantanen committed Nov 8, 2024
1 parent ce982e3 commit b4e176a
Show file tree
Hide file tree
Showing 8 changed files with 2,773 additions and 350 deletions.
1,549 changes: 1,381 additions & 168 deletions updater/sis-updater-scheduler/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions updater/sis-updater-scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"node-nats-streaming": "^0.3.2",
"pg": "^8.11.5",
"redis": "^4.7.0",
"winston": "^3.13.0",
"winston": "^3.16.0",
"winston-gelf-transporter": "^1.0.2",
"winston-sentry-log": "^1.0.26"
"winston-transport-sentry-node": "^3.0.0"
},
"devDependencies": {
"nodemon": "^3.1.0"
Expand Down
5 changes: 0 additions & 5 deletions updater/sis-updater-scheduler/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,4 @@ module.exports.ENABLE_WORKER_REPORTING =
module.exports.EXIT_AFTER_IMMEDIATES || process.env.ENABLE_WORKER_REPORTING === 'yes'
module.exports.SLACK_WEBHOOK = process.env.SLACK_WEBHOOK
module.exports.serviceProvider = process.env.SERVICE_PROVIDER ? process.env.SERVICE_PROVIDER.toLowerCase() : ''

// Sentry
module.exports.sentryRelease = process.env.SENTRY_RELEASE || ''
module.exports.sentryEnvironment = process.env.SENTRY_ENVIRONMENT || ''
module.exports.sentryDSN = process.env.SENTRY_DSN || ''
module.exports.runningInCI = process.env.CI === 'true'
26 changes: 4 additions & 22 deletions updater/sis-updater-scheduler/src/utils/logger.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,18 @@
const os = require('os')
const winston = require('winston')
const { WinstonGelfTransporter } = require('winston-gelf-transporter')
const Sentry = require('winston-sentry-log')
const Sentry = require('winston-transport-sentry-node').default

const {
isDev,
isStaging,
isProduction,
sentryRelease,
sentryEnvironment,
sentryDSN,
runningInCI,
serviceProvider,
} = require('../config')
const { isDev, isStaging, isProduction, runningInCI, serviceProvider } = require('../config')

const { combine, timestamp, printf, splat } = winston.format

const formatDate = timestamp => new Date(timestamp).toLocaleString('fi-FI')

const transports = []

if (isProduction && !isStaging && !runningInCI && sentryDSN) {
const options = {
config: {
dsn: sentryDSN,
environment: sentryEnvironment,
release: sentryRelease,
},
level: 'error',
}

transports.push(new Sentry(options))
if (isProduction && !isStaging && !runningInCI && process.env.SENTRY_DSN) {
transports.push(new Sentry({ level: 'error' }))
}

if (isDev) {
Expand Down
Loading

0 comments on commit b4e176a

Please sign in to comment.