mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(core): add logger timestamp (#13165)
* feat(core): add logger timestamp * Update website/docs/install/README.md ---------
This commit is contained in:
@@ -94,6 +94,7 @@ const calculateValue = () => {
|
||||
debugInfo: envs.DEBUG_INFO || 'true',
|
||||
loggerLevel: envs.LOGGER_LEVEL || 'info',
|
||||
noLogfiles: envs.NO_LOGFILES,
|
||||
showLoggerTimestamp: envs.SHOW_LOGGER_TIMESTAMP,
|
||||
sentry: {
|
||||
dsn: envs.SENTRY,
|
||||
routeTimeout: parseInt(envs.SENTRY_ROUTE_TIMEOUT) || 30000,
|
||||
|
||||
+14
-2
@@ -14,7 +14,16 @@ if (!config.noLogfiles) {
|
||||
}
|
||||
const logger = winston.createLogger({
|
||||
level: config.loggerLevel,
|
||||
format: winston.format.json(),
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }),
|
||||
winston.format.printf((info) =>
|
||||
JSON.stringify({
|
||||
timestamp: info.timestamp,
|
||||
level: info.level,
|
||||
message: info.message,
|
||||
})
|
||||
)
|
||||
),
|
||||
transports,
|
||||
});
|
||||
|
||||
@@ -25,7 +34,10 @@ const logger = winston.createLogger({
|
||||
if (!config.isPackage) {
|
||||
logger.add(
|
||||
new winston.transports.Console({
|
||||
format: winston.format.combine(winston.format.colorize(), winston.format.simple()),
|
||||
format: winston.format.printf((info) => {
|
||||
const infoLevel = winston.format.colorize().colorize(info.level, config.showLoggerTimestamp ? `[${info.timestamp}] ${info.level}` : info.level);
|
||||
return `${infoLevel}: ${info.message}`;
|
||||
}),
|
||||
silent: process.env.NODE_ENV === 'test',
|
||||
})
|
||||
);
|
||||
|
||||
@@ -677,6 +677,8 @@ See the relation between access key/code and white/blacklisting.
|
||||
|
||||
`NO_LOGFILES`: disable logging to log files, default to `false`
|
||||
|
||||
`SHOW_LOGGER_TIMESTAMP`: Show timestamp in log, default to `false`
|
||||
|
||||
`SENTRY`: [Sentry](https://sentry.io) dsn, used for error tracking
|
||||
|
||||
`SENTRY_ROUTE_TIMEOUT`: Report Sentry if route execution takes more than this milliseconds, default to `3000`
|
||||
|
||||
@@ -672,6 +672,8 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
|
||||
|
||||
`NO_LOGFILES`: 是否禁用日志文件输出,默认 `false`
|
||||
|
||||
`SHOW_LOGGER_TIMESTAMP`: 在控制台输出中显示日志时间戳,默认 `false`
|
||||
|
||||
`SENTRY`: [Sentry](https://sentry.io) dsn,用于错误追踪
|
||||
|
||||
`SENTRY_ROUTE_TIMEOUT`: 路由耗时超过此毫秒值上报 Sentry,默认 `3000`
|
||||
|
||||
Reference in New Issue
Block a user