-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from swoocn/revert-40-backend-logging-framework
Self-approved; revert changes.
- Loading branch information
Showing
16 changed files
with
198 additions
and
1,162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
const winston = require('winston'); | ||
const configureLogging = require('./logging-config'); | ||
|
||
const initializeLogger = async () => { | ||
try { | ||
const loggingConfig = await configureLogging(); | ||
const logger = winston.createLogger(loggingConfig); | ||
return logger; | ||
} catch (error) { | ||
console.error('Error initializing logger:', error); | ||
return null; | ||
} | ||
}; | ||
const loggingConfig = configureLogging(); | ||
const logger = winston.createLogger(loggingConfig); | ||
|
||
module.exports = initializeLogger; | ||
module.exports = logger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,34 @@ | ||
const dotenv = require("dotenv"); | ||
const winston = require('winston'); | ||
const connectDB = require("./mongodb"); | ||
|
||
require('winston-mongodb'); | ||
|
||
dotenv.config(); | ||
|
||
const configureLogging = async () => { | ||
// console.log(`VERCEL_ENV: ${process.env.VERCEL_ENV}`); | ||
const configureLogging = () => { | ||
console.log(`VERCEL_ENV: ${process.env.VERCEL_ENV}`); | ||
|
||
// check if the app is running in localhost mode or sandbox | ||
const isDevelopment = () => { | ||
return process.env.VERCEL_ENV === "localhost" || process.env.VERCEL_ENV === "sandbox"; | ||
}; | ||
|
||
// determine the logging configuration based on the server environment | ||
// determine the logging configuration based on the environment | ||
if (isDevelopment()) { | ||
return { | ||
level: 'debug', | ||
format: winston.format.combine( | ||
winston.format.errors({ stack: true }), | ||
winston.format.cli() | ||
), | ||
format: winston.format.cli(), | ||
transports: [ | ||
new winston.transports.Console() | ||
] | ||
}; | ||
} else { | ||
await connectDB(); | ||
|
||
return { | ||
level: 'info', | ||
format: winston.format.combine( | ||
winston.format.errors({ stack: true }), | ||
winston.format.timestamp(), // GMT | ||
winston.format.json() | ||
), | ||
level: 'error', | ||
format: winston.format.cli(), | ||
transports: [ | ||
new winston.transports.MongoDB({ | ||
db: process.env.MONGODB_URL, | ||
options: { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true | ||
}, | ||
collection: 'serverLogs' | ||
}) | ||
new winston.transports.Console() | ||
] | ||
}; | ||
} | ||
}; | ||
} | ||
|
||
module.exports = configureLogging; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.