Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1281: add new global option --errorLog #1282

Merged
Merged
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
6 changes: 5 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,12 @@ yargs(hideBin(process.argv))
description: 'Interactive questions where possible and go with defaults instead',
})
.option('api', {
description: 'Print API calls to log ',
choices: ['log', 'cli'],
description: 'Print API calls to log',
})
.option('errorLog', {
type: 'boolean',
description: 'Create a second log file that only contains error messages',
})
.demandCommand(1, 'Please enter a valid command')
.strict()
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Mcdev {
'changeKeyField',
'changeKeyValue',
'commitHistory',
'errorLog',
'execute',
'filter',
'fixShared',
Expand Down
31 changes: 17 additions & 14 deletions lib/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,20 +315,23 @@ export const Util = {
)
),
});
transports.fileError = new winston.transports.File({
// Write logs to additional error-logfile for better visibility of errors
filename: 'logs/' + logFileName + '-errors.log',
level: 'error', // only log errors
lazy: true, // if true, log files will be created on demand, not at the initialization time.
format: winston.format.combine(
winston.format.uncolorize(),
winston.format.timestamp({ format: 'HH:mm:ss.SSS' }),
winston.format.simple(),
winston.format.printf(
(info) => `${info.timestamp} ${info.level}: ${info.message}`
)
),
});
if (Util.OPTIONS.errorLog) {
// used by CI/CD solutions like Copado to quickly show the error message to admins/users
transports.fileError = new winston.transports.File({
// Write logs to additional error-logfile for better visibility of errors
filename: 'logs/' + logFileName + '-errors.log',
level: 'error', // only log errors
lazy: true, // if true, log files will be created on demand, not at the initialization time.
format: winston.format.combine(
winston.format.uncolorize(),
winston.format.timestamp({ format: 'HH:mm:ss.SSS' }),
winston.format.simple(),
winston.format.printf(
(info) => `${info.timestamp} ${info.level}: ${info.message}`
)
),
});
}
}
return transports;
},
Expand Down
Loading