feat(backend): configurable log levels for troubleshooting
This commit is contained in:
parent
97a871f1a6
commit
e7689fb302
3 changed files with 17 additions and 2 deletions
|
@ -167,6 +167,17 @@ reservedUsernames: [
|
||||||
# IP address family used for outgoing request (ipv4, ipv6 or dual)
|
# IP address family used for outgoing request (ipv4, ipv6 or dual)
|
||||||
#outgoingAddressFamily: ipv4
|
#outgoingAddressFamily: ipv4
|
||||||
|
|
||||||
|
# Log Option
|
||||||
|
# Production env: ['error', 'success', 'warning', 'info']
|
||||||
|
# Debug/Test env or Troubleshooting: ['error', 'success', 'warning', 'debug' ,'info']
|
||||||
|
# Production env which storage space or IO is tight: ['error', 'warning']
|
||||||
|
logLevel: [
|
||||||
|
'error',
|
||||||
|
'success',
|
||||||
|
'warning',
|
||||||
|
'info'
|
||||||
|
]
|
||||||
|
|
||||||
# Syslog option
|
# Syslog option
|
||||||
#syslog:
|
#syslog:
|
||||||
# host: localhost
|
# host: localhost
|
||||||
|
|
|
@ -89,6 +89,8 @@ export type Source = {
|
||||||
deliverJobMaxAttempts?: number;
|
deliverJobMaxAttempts?: number;
|
||||||
inboxJobMaxAttempts?: number;
|
inboxJobMaxAttempts?: number;
|
||||||
|
|
||||||
|
logLevel?: string[];
|
||||||
|
|
||||||
syslog: {
|
syslog: {
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
|
|
|
@ -57,6 +57,7 @@ export default class Logger {
|
||||||
store = true,
|
store = true,
|
||||||
): void {
|
): void {
|
||||||
if (envOption.quiet) return;
|
if (envOption.quiet) return;
|
||||||
|
if (!(typeof config.logLevel === "undefined") && !config.logLevel.includes(level)) return;
|
||||||
if (!this.store) store = false;
|
if (!this.store) store = false;
|
||||||
if (level === "debug") store = false;
|
if (level === "debug") store = false;
|
||||||
|
|
||||||
|
@ -186,8 +187,9 @@ export default class Logger {
|
||||||
data?: Record<string, any> | null,
|
data?: Record<string, any> | null,
|
||||||
important = false,
|
important = false,
|
||||||
): void {
|
): void {
|
||||||
// デバッグ用に使う(開発者に必要だが利用者に不要な情報)
|
// Used for debugging (information necessary for developers but unnecessary for users)
|
||||||
if (process.env.NODE_ENV !== "production" || envOption.verbose) {
|
// Fixed if statement is ignored when logLevel includes debug
|
||||||
|
if (config.logLevel?.includes("debug") || process.env.NODE_ENV !== "production" || envOption.verbose) {
|
||||||
this.log("debug", message, data, important);
|
this.log("debug", message, data, important);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue