Skip to content
Snippets Groups Projects
Commit 15810e93 authored by Markus Grigull's avatar Markus Grigull
Browse files

Minor improvements

Fix file log level
Add and improve log messages
Change mongoose logging to debug log level
parent f7a753dc
No related branches found
No related tags found
1 merge request!5Resolve "Add log level config option"
This commit is part of merge request !5. Comments created here will be created in the context of that merge request.
......@@ -26,7 +26,7 @@ module.exports = {
databaseURL: 'mongodb://localhost:27017/',
port: 4000,
secret: 'longsecretislong',
logLevel: 'verbose',
logLevel: 'verbose', // possible values: error, warn, info, verbose or debug
logFile: 'log.txt',
admin: {
username: 'admin',
......@@ -38,7 +38,7 @@ module.exports = {
databaseURL: 'mongodb://database:27017/',
port: 4000,
secret: 'longsecretislong',
logLevel: 'warn',
logLevel: 'warn', // possible values: error, warn, info, verbose or debug
logFile: 'villasweb-backend_log.txt',
admin: {
username: 'admin',
......
......@@ -51,19 +51,22 @@ var config = require('./config')[app.get('env')];
if (config.logLevel) {
logger.transports.console.level = config.logLevel;
// enable debug output for verbose
if (config.logLevel == 'verbose') {
// enable debug output for mongoose
if (config.logLevel == 'debug' || config.logLevel == 'silly') {
mongoose.set('debug', function(coll, method, query, doc) {
logger.log('verbose', '[Mongoose]', { coll, method, query, doc });
logger.log('debug', '[Mongoose]', { coll, method, query, doc });
});
}
}
if (config.logFile) {
logger.transports.file.filename = config.logFile;
logger.transports.file.level = config.logLevel;
logger.transports.file.silent = false;
}
logger.info('--- Started VILLASweb backend ---');
// configure app
app.use(expressWinston.logger({ winstonInstance: logger }));
app.use(bodyParser.json());
......@@ -111,7 +114,7 @@ app.use(function(err, req, res, next) {
// start the app
app.listen(config.port, function() {
logger.info('Express server listening on port ' + config.port);
logger.info('Server listening on port ' + config.port);
});
// add admin account
......
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