Skip to content
Snippets Groups Projects
Commit 39b14651 authored by P1375's avatar P1375
Browse files

Revert "Merge branch 'loggers' into 'master'"

This reverts merge request !7
parent 8c96988f
No related branches found
No related tags found
1 merge request!8Revert "Merge branch 'loggers' into 'master'"
const logger = require('./logger')
var http = require('http'), var http = require('http'),
path = require('path'), path = require('path'),
methods = require('methods'), methods = require('methods'),
...@@ -16,16 +14,6 @@ var isProduction = process.env.NODE_ENV === 'production'; ...@@ -16,16 +14,6 @@ var isProduction = process.env.NODE_ENV === 'production';
// Create global app object // Create global app object
var app = express(); var app = express();
app.use((req, res, next) => {
logger.info(req.body)
let origSend = res.send
res.send = function(data) {
logger.info(data)
origSend.apply(res, arguments)
}
next()
})
app.use(cors()); app.use(cors());
// Normal express config defaults // Normal express config defaults
...@@ -69,7 +57,7 @@ app.use(function(req, res, next) { ...@@ -69,7 +57,7 @@ app.use(function(req, res, next) {
// will print stacktrace // will print stacktrace
if (!isProduction) { if (!isProduction) {
app.use(function(err, req, res, next) { app.use(function(err, req, res, next) {
logger.info(err.stack); console.log(err.stack);
res.status(err.status || 500); res.status(err.status || 500);
...@@ -92,5 +80,5 @@ app.use(function(err, req, res, next) { ...@@ -92,5 +80,5 @@ app.use(function(err, req, res, next) {
// finally, let's start our server... // finally, let's start our server...
var server = app.listen( process.env.PORT || 3000, function(){ var server = app.listen( process.env.PORT || 3000, function(){
logger.info('Listening on port ' + server.address().port); console.log('Listening on port ' + server.address().port);
}); });
const {​​​​​ createLogger, transports, format }​​​​​ = require('winston')
constlogger = createLogger({​​​​​
transports: [
newtransports.File({​​​​​
filename:'error.log',
level:'error',
format:format.combine(format.timestamp(), format.json())
}​​​​​),
newtransports.File({​​​​​
filename:'info.log',
level:'info',
format:format.combine(format.timestamp(), format.json())
}​​​​​),
newtransports.Console({​​​​​
level:'info',
format:format.combine(format.timestamp(), format.colorize(), format.json())
}​​​​​)
]
}​​​​​)
module.exports = logger
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment