Skip to content

Commit

Permalink
refactor(logger): run only on staging and prod
Browse files Browse the repository at this point in the history
  • Loading branch information
yossi-eynav committed Apr 21, 2024
1 parent 4da3a72 commit d303194
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions server/api/lib/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ const os = require('os');
const util = require('util')
const Config = require('./config');

const apikey = Config.get('coralogix.apikey');
const serviceName = Config.get('coralogix.serviceName');
const host = Config.get('coralogix.host');
const transports = [
new winston.transports.Console()
]

const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
defaultMeta: { version: process.env.VERSION, env: process.env.NODE_ENV },
transports: [
new winston.transports.Console(),
if (process.env.NODE_ENV === "staging" || process.env.NODE_ENV === "production") {
const apikey = Config.get('coralogix.apikey');
const serviceName = Config.get('coralogix.serviceName');
const host = Config.get('coralogix.host');

transports.push(
new winston.transports.Http({
name: "coralogix",
level: "info",
Expand Down Expand Up @@ -59,7 +59,14 @@ const logger = winston.createLogger({
batchInterval: 1000,
handleExceptions: true,
}),
]
)

}
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
defaultMeta: { version: process.env.VERSION, env: process.env.NODE_ENV },
transports,
});

module.exports = {
Expand Down

0 comments on commit d303194

Please sign in to comment.