mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 08:04:51 +00:00
Display better logs
This commit is contained in:
parent
800945eb32
commit
b89a8a5abc
@ -26,7 +26,8 @@ module.exports = {
|
||||
|
||||
// Verify if the file upload is enable.
|
||||
if (config.enabled === false) {
|
||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Upload.status.disabled' }] }] : 'The file upload is disabled!');
|
||||
strapi.log.error('File upload is disabled');
|
||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Upload.status.disabled' }] }] : 'File upload is disabled');
|
||||
}
|
||||
|
||||
// Extract optional relational data.
|
||||
|
||||
@ -28,8 +28,20 @@ function getBool(envVar, defaultValue) {
|
||||
const loggerConfig = {
|
||||
level: getLogLevel(),
|
||||
timestamp: getBool(process.env.STRAPI_LOG_TIMESTAMP, false),
|
||||
prettyPrint: getBool(process.env.STRAPI_LOG_PRETTY_PRINT, true),
|
||||
forceColor: getBool(process.env.STRAPI_LOG_FORCE_COLOR, true),
|
||||
// prettyPrint: getBool(process.env.STRAPI_LOG_PRETTY_PRINT, true),
|
||||
forceColor: getBool(process.env.STRAPI_LOG_FORCE_COLOR, true)
|
||||
};
|
||||
|
||||
module.exports = pino(loggerConfig);
|
||||
const pretty = pino.pretty({
|
||||
formatter: (logs, options) => {
|
||||
return `\u001b[90m[${new Date().toISOString()}] ${options.prefix.toLowerCase()} ${options.asColoredText(logs.level, logs.msg)}`;
|
||||
}
|
||||
});
|
||||
|
||||
pretty.pipe(process.stdout);
|
||||
|
||||
const logger = getBool(process.env.STRAPI_LOG_PRETTY_PRINT, true) ?
|
||||
pino(loggerConfig, pretty):
|
||||
pino(loggerConfig);
|
||||
|
||||
module.exports = logger;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user