mirror of
https://github.com/aurora-dot/pastel.codes.git
synced 2024-11-22 08:12:19 +00:00
Please please work
This commit is contained in:
parent
a2d1ab36d3
commit
3fa325d4fc
35
app.js
35
app.js
@ -2,9 +2,7 @@ var createError = require('http-errors');
|
|||||||
var express = require('express');
|
var express = require('express');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var cookieParser = require('cookie-parser');
|
var cookieParser = require('cookie-parser');
|
||||||
var logger = require('morgan');
|
|
||||||
var sassMiddleware = require('node-sass-middleware');
|
var sassMiddleware = require('node-sass-middleware');
|
||||||
var winston = require('./config/winston');
|
|
||||||
|
|
||||||
var indexRouter = require('./routes/index');
|
var indexRouter = require('./routes/index');
|
||||||
var aboutRouter = require('./routes/about');
|
var aboutRouter = require('./routes/about');
|
||||||
@ -18,10 +16,37 @@ app.disable('x-powered-by');
|
|||||||
app.set('views', path.join(__dirname, 'views'));
|
app.set('views', path.join(__dirname, 'views'));
|
||||||
app.set('view engine', 'pug');
|
app.set('view engine', 'pug');
|
||||||
|
|
||||||
|
var logger = new winston.Logger({
|
||||||
|
transports: [
|
||||||
|
new winston.transports.File({
|
||||||
|
level: 'info',
|
||||||
|
filename: './logs/all-logs.log',
|
||||||
|
handleExceptions: true,
|
||||||
|
json: true,
|
||||||
|
maxsize: 5242880, //5MB
|
||||||
|
maxFiles: 5,
|
||||||
|
colorize: false
|
||||||
|
}),
|
||||||
|
new ston.transportswin.Console({
|
||||||
|
level: 'debug',
|
||||||
|
handleExceptions: true,
|
||||||
|
json: false,
|
||||||
|
colorize: true
|
||||||
|
})
|
||||||
|
],
|
||||||
|
exitOnError: false
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.stream = {
|
||||||
|
write: function(message, encoding){
|
||||||
|
logger.info(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
app.use(logger('combined', { stream: winston.stream }));
|
app.use(require("morgan")("common", { "stream": logger.stream }));
|
||||||
} else {
|
} else {
|
||||||
app.use(logger('dev'));
|
app.use(require(morgan)('dev'));
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
@ -49,8 +74,6 @@ app.use(function(err, req, res, next) {
|
|||||||
res.locals.message = err.message;
|
res.locals.message = err.message;
|
||||||
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
||||||
|
|
||||||
winston.error(`${err.status || 500} - ${err.message} - ${req.originalUrl} - ${req.method} - ${req.ip}`);
|
|
||||||
|
|
||||||
// render the error page
|
// render the error page
|
||||||
res.status(err.status || 500);
|
res.status(err.status || 500);
|
||||||
res.render('error', { title: 'Error', description: "Error" });
|
res.render('error', { title: 'Error', description: "Error" });
|
||||||
|
Loading…
Reference in New Issue
Block a user