mirror of
https://github.com/aurora-dot/pastel.codes.git
synced 2024-11-22 08:12:19 +00:00
Fixed??
This commit is contained in:
parent
c5638a4552
commit
76190ef7d8
34
app.js
34
app.js
@ -2,8 +2,9 @@ var createError = require('http-errors');
|
||||
var express = require('express');
|
||||
var path = require('path');
|
||||
var cookieParser = require('cookie-parser');
|
||||
var mLogger = require('morgan');
|
||||
var sassMiddleware = require('node-sass-middleware');
|
||||
var winston = require('winston');
|
||||
var logger = require('./config/winston');
|
||||
|
||||
var indexRouter = require('./routes/index');
|
||||
var aboutRouter = require('./routes/about');
|
||||
@ -17,37 +18,10 @@ app.disable('x-powered-by');
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
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') {
|
||||
app.use(require("morgan")("common", { "stream": logger.stream }));
|
||||
app.use(mLogger("common", { "stream": logger.stream }));
|
||||
} else {
|
||||
app.use(require(morgan)('dev'));
|
||||
app.use(mLogger('dev'));
|
||||
}
|
||||
|
||||
app.use(express.json());
|
||||
|
@ -1,41 +1,29 @@
|
||||
var appRoot = require('app-root-path');
|
||||
var winston = require('winston');
|
||||
|
||||
// define the custom settings for each transport (file, console)
|
||||
var options = {
|
||||
file: {
|
||||
var logger = new winston.createLogger({
|
||||
transports: [
|
||||
new winston.transports.File({
|
||||
level: 'info',
|
||||
filename: `${appRoot}/logs/app.log`,
|
||||
filename: './logs/all-logs.log',
|
||||
handleExceptions: true,
|
||||
json: true,
|
||||
maxsize: 5242880, // 5MB
|
||||
maxsize: 5242880, //5MB
|
||||
maxFiles: 5,
|
||||
colorize: false,
|
||||
},
|
||||
console: {
|
||||
colorize: false
|
||||
}),
|
||||
new winston.transports.Console({
|
||||
level: 'debug',
|
||||
handleExceptions: true,
|
||||
json: false,
|
||||
colorize: true,
|
||||
},
|
||||
};
|
||||
|
||||
// instantiate a new Winston Logger with the settings defined above
|
||||
let logger = winston.createLogger({
|
||||
transports: [
|
||||
new (winston.transports.Console)(options.console),
|
||||
new (winston.transports.File)(options.errorFile),
|
||||
new (winston.transports.File)(options.file)
|
||||
colorize: true
|
||||
})
|
||||
],
|
||||
exitOnError: false, // do not exit on handled exceptions
|
||||
exitOnError: false
|
||||
});
|
||||
|
||||
// create a stream object with a 'write' function that will be used by `morgan`
|
||||
logger.stream = {
|
||||
write: function(message, encoding) {
|
||||
// use the 'info' log level so the output will be picked up by both transports (file and console)
|
||||
write: function(message, encoding){
|
||||
logger.info(message);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = logger;
|
||||
module.exports = logger
|
Loading…
Reference in New Issue
Block a user