forked from FoundKeyGang/FoundKey
parent
2c3f731ae2
commit
ff66f48ea2
5 changed files with 1 additions and 63 deletions
|
@ -108,11 +108,6 @@ redis:
|
||||||
#deliverJobMaxAttempts: 12
|
#deliverJobMaxAttempts: 12
|
||||||
#inboxJobMaxAttempts: 8
|
#inboxJobMaxAttempts: 8
|
||||||
|
|
||||||
# Syslog option
|
|
||||||
#syslog:
|
|
||||||
# host: localhost
|
|
||||||
# port: 514
|
|
||||||
|
|
||||||
# Proxy for HTTP/HTTPS outgoing connections
|
# Proxy for HTTP/HTTPS outgoing connections
|
||||||
#proxy: http://127.0.0.1:3128
|
#proxy: http://127.0.0.1:3128
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,6 @@
|
||||||
"stringz": "2.1.0",
|
"stringz": "2.1.0",
|
||||||
"style-loader": "3.3.1",
|
"style-loader": "3.3.1",
|
||||||
"summaly": "2.7.0",
|
"summaly": "2.7.0",
|
||||||
"syslog-pro": "1.0.0",
|
|
||||||
"systeminformation": "5.11.22",
|
"systeminformation": "5.11.22",
|
||||||
"tinycolor2": "1.4.2",
|
"tinycolor2": "1.4.2",
|
||||||
"tmp": "0.2.1",
|
"tmp": "0.2.1",
|
||||||
|
@ -158,7 +157,6 @@
|
||||||
"@types/sinon": "^10.0.13",
|
"@types/sinon": "^10.0.13",
|
||||||
"@types/sinonjs__fake-timers": "8.1.2",
|
"@types/sinonjs__fake-timers": "8.1.2",
|
||||||
"@types/speakeasy": "2.0.7",
|
"@types/speakeasy": "2.0.7",
|
||||||
"@types/syslog-pro": "^1.0.0",
|
|
||||||
"@types/tinycolor2": "1.4.3",
|
"@types/tinycolor2": "1.4.3",
|
||||||
"@types/tmp": "0.2.3",
|
"@types/tmp": "0.2.3",
|
||||||
"@types/uuid": "8.3.4",
|
"@types/uuid": "8.3.4",
|
||||||
|
|
|
@ -59,11 +59,6 @@ export type Source = {
|
||||||
deliverJobMaxAttempts?: number;
|
deliverJobMaxAttempts?: number;
|
||||||
inboxJobMaxAttempts?: number;
|
inboxJobMaxAttempts?: number;
|
||||||
|
|
||||||
syslog?: {
|
|
||||||
host: string;
|
|
||||||
port: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
mediaProxy?: string;
|
mediaProxy?: string;
|
||||||
proxyRemoteFiles?: boolean;
|
proxyRemoteFiles?: boolean;
|
||||||
internalStoragePath?: string;
|
internalStoragePath?: string;
|
||||||
|
|
|
@ -2,7 +2,6 @@ import cluster from 'node:cluster';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import convertColor from 'color-convert';
|
import convertColor from 'color-convert';
|
||||||
import { format as dateFormat } from 'date-fns';
|
import { format as dateFormat } from 'date-fns';
|
||||||
import * as SyslogPro from 'syslog-pro';
|
|
||||||
import config from '@/config/index.js';
|
import config from '@/config/index.js';
|
||||||
import { envOption } from '@/env.js';
|
import { envOption } from '@/env.js';
|
||||||
import type { KEYWORD } from 'color-convert/conversions.js';
|
import type { KEYWORD } from 'color-convert/conversions.js';
|
||||||
|
@ -22,13 +21,12 @@ export const LEVELS = {
|
||||||
export type Level = LEVELS[keyof LEVELS];
|
export type Level = LEVELS[keyof LEVELS];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that facilitates recording log messages to the console and optionally a syslog server.
|
* Class that facilitates recording log messages to the console.
|
||||||
*/
|
*/
|
||||||
export default class Logger {
|
export default class Logger {
|
||||||
private domain: Domain;
|
private domain: Domain;
|
||||||
private parentLogger: Logger | null = null;
|
private parentLogger: Logger | null = null;
|
||||||
private store: boolean;
|
private store: boolean;
|
||||||
private syslogClient: SyslogPro.RFC5424 | null = null;
|
|
||||||
/**
|
/**
|
||||||
* Messages below this level will be discarded.
|
* Messages below this level will be discarded.
|
||||||
*/
|
*/
|
||||||
|
@ -47,20 +45,6 @@ export default class Logger {
|
||||||
};
|
};
|
||||||
this.store = store;
|
this.store = store;
|
||||||
this.minLevel = minLevel;
|
this.minLevel = minLevel;
|
||||||
|
|
||||||
if (config.syslog) {
|
|
||||||
this.syslogClient = new SyslogPro.RFC5424({
|
|
||||||
applicationName: 'FoundKey',
|
|
||||||
timestamp: true,
|
|
||||||
includeStructuredData: true,
|
|
||||||
color: true,
|
|
||||||
extendedColor: true,
|
|
||||||
server: {
|
|
||||||
target: config.syslog.host,
|
|
||||||
port: config.syslog.port,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,15 +123,6 @@ export default class Logger {
|
||||||
if (envOption.withLogTime) log = chalk.gray(time) + ' ' + log;
|
if (envOption.withLogTime) log = chalk.gray(time) + ' ' + log;
|
||||||
|
|
||||||
console.log(important ? chalk.bold(log) : log);
|
console.log(important ? chalk.bold(log) : log);
|
||||||
|
|
||||||
if (store && this.syslogClient) {
|
|
||||||
const send =
|
|
||||||
level === LEVELS.error ? this.syslogClient.error :
|
|
||||||
level === LEVELS.warning ? this.syslogClient.warning :
|
|
||||||
this.syslogClient.info;
|
|
||||||
|
|
||||||
send.bind(this.syslogClient)(message).catch(() => {});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
25
yarn.lock
25
yarn.lock
|
@ -2443,13 +2443,6 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@types/syslog-pro@npm:^1.0.0":
|
|
||||||
version: 1.0.0
|
|
||||||
resolution: "@types/syslog-pro@npm:1.0.0"
|
|
||||||
checksum: d0dcd87efad8a629bba449f86a617605a3fbffa5c18a8b309c82e7b85036ac21cfd34711fd522f50528dd0f0d07bdb66261a6f9ef20f2a9133e847b2e717c1bc
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"@types/throttle-debounce@npm:5.0.0":
|
"@types/throttle-debounce@npm:5.0.0":
|
||||||
version: 5.0.0
|
version: 5.0.0
|
||||||
resolution: "@types/throttle-debounce@npm:5.0.0"
|
resolution: "@types/throttle-debounce@npm:5.0.0"
|
||||||
|
@ -3702,7 +3695,6 @@ __metadata:
|
||||||
"@types/sinon": ^10.0.13
|
"@types/sinon": ^10.0.13
|
||||||
"@types/sinonjs__fake-timers": 8.1.2
|
"@types/sinonjs__fake-timers": 8.1.2
|
||||||
"@types/speakeasy": 2.0.7
|
"@types/speakeasy": 2.0.7
|
||||||
"@types/syslog-pro": ^1.0.0
|
|
||||||
"@types/tinycolor2": 1.4.3
|
"@types/tinycolor2": 1.4.3
|
||||||
"@types/tmp": 0.2.3
|
"@types/tmp": 0.2.3
|
||||||
"@types/uuid": 8.3.4
|
"@types/uuid": 8.3.4
|
||||||
|
@ -3792,7 +3784,6 @@ __metadata:
|
||||||
stringz: 2.1.0
|
stringz: 2.1.0
|
||||||
style-loader: 3.3.1
|
style-loader: 3.3.1
|
||||||
summaly: 2.7.0
|
summaly: 2.7.0
|
||||||
syslog-pro: 1.0.0
|
|
||||||
systeminformation: 5.11.22
|
systeminformation: 5.11.22
|
||||||
tinycolor2: 1.4.2
|
tinycolor2: 1.4.2
|
||||||
tmp: 0.2.1
|
tmp: 0.2.1
|
||||||
|
@ -12044,13 +12035,6 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"moment@npm:^2.22.2":
|
|
||||||
version: 2.29.4
|
|
||||||
resolution: "moment@npm:2.29.4"
|
|
||||||
checksum: 0ec3f9c2bcba38dc2451b1daed5daded747f17610b92427bebe1d08d48d8b7bdd8d9197500b072d14e326dd0ccf3e326b9e3d07c5895d3d49e39b6803b76e80e
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"ms@npm:2.0.0":
|
"ms@npm:2.0.0":
|
||||||
version: 2.0.0
|
version: 2.0.0
|
||||||
resolution: "ms@npm:2.0.0"
|
resolution: "ms@npm:2.0.0"
|
||||||
|
@ -16141,15 +16125,6 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"syslog-pro@npm:1.0.0":
|
|
||||||
version: 1.0.0
|
|
||||||
resolution: "syslog-pro@npm:1.0.0"
|
|
||||||
dependencies:
|
|
||||||
moment: ^2.22.2
|
|
||||||
checksum: 7d6399e4ca3a9305758f77b3e720469b39c156b5a8219ed4ce27b4ad8f960f8e395aebb0ccc84e4438b50a6b2cda2e20251e278307833ed7ac1045ae9516a33c
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"systeminformation@npm:5.11.22":
|
"systeminformation@npm:5.11.22":
|
||||||
version: 5.11.22
|
version: 5.11.22
|
||||||
resolution: "systeminformation@npm:5.11.22"
|
resolution: "systeminformation@npm:5.11.22"
|
||||||
|
|
Loading…
Reference in a new issue