Skip to content

Commit

Permalink
Merge pull request #1020 from pokt-foundation/dd-removal-fix
Browse files Browse the repository at this point in the history
fix: only prod/staging loki
  • Loading branch information
crisog authored Jan 10, 2023
2 parents 3d565dd + 0be5faa commit 2ce7627
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/services/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require('dotenv').config()
const { createLogger, format, transports: winstonTransports } = require('winston')
const LokiWinston = require('winston-loki')

const environment = process.env.NODE_ENV || 'production'
const accessKeyID = process.env.AWS_ACCESS_KEY_ID || ''
const awsSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY || ''
const region = process.env.REGION || ''
Expand Down Expand Up @@ -68,12 +69,18 @@ const options = {
const getTransports = () => {
const transports = [new winstonTransports.Console(options.console)]

if (logToLoki) {
if (!lokiHost) {
throw new HttpErrors.InternalServerError('LOKI_HOST required in ENV')
}
if (environment === 'production' || environment === 'staging') {
if (logToLoki) {
if (!lokiHost) {
throw new HttpErrors.InternalServerError('LOKI_HOST required in ENV')
}

if (!region) {
throw new HttpErrors.InternalServerError('REGION required in ENV')
}

transports.push(new LokiWinston(options.loki))
transports.push(new LokiWinston(options.loki))
}
}

return transports
Expand Down

0 comments on commit 2ce7627

Please sign in to comment.