Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
src/node_modules
src/node_modules
*.log
src/.env
2 changes: 2 additions & 0 deletions src/config/main-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// *** main dependencies *** //
const bodyParser = require('body-parser');
const path = require('path');

require('dotenv').config();

appConfig.init = function (app, express) {
app.set('view engine', 'html');
Expand Down
42 changes: 42 additions & 0 deletions src/helpers/winston.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* winston.js - LearnDB
*
* Kevin Kelly
* Data Science & Systems Lab (DASSL)
* https://dassl.github.io/
*
* (C) 2019- DASSL. ALL RIGHTS RESERVED.
* Licensed to others under CC 4.0 BY-SA-NC
* https://creativecommons.org/licenses/by-nc-sa/4.0/
*
* PROVIDED AS IS. NO WARRANTIES EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*
* This file contains the logging functionality
*/


const { createLogger, format, transports } = require('winston');

const {
combine, timestamp, printf,
} = format;

const myFormat = printf(info => `${info.timestamp} ${info.level}: ${info.message}`);

const logger = createLogger({
format: combine(
timestamp(),
myFormat,
),
transports: [
new transports.File({ filename: `${process.env.PATH_TO_LOGS}/error.log`, level: 'error' }),
new transports.File({ filename: `${process.env.PATH_TO_LOGS}/combined.log` }),
],
});

module.exports = logger;
module.exports.stream = {
write(message) {
logger.info(message);
},
};
Loading