fix: replace winston with pino #6
@@ -2,7 +2,8 @@
|
||||
"scripts": {
|
||||
"build": "bun build --minify --target bun --outdir dist --sourcemap src/app.ts",
|
||||
"check:code": "eslint src/ --ext .ts",
|
||||
"check:spell": "cspell --config cspell.code.json **/*.ts"
|
||||
"check:spell": "cspell --config cspell.code.json **/*.ts",
|
||||
"start": "bun run src/app.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ts3-nodejs-library": "^2.0.1",
|
||||
@@ -16,8 +17,9 @@
|
||||
"dependencies": {
|
||||
"env-var": "^7.5.0",
|
||||
"gotify": "^1.1.0",
|
||||
"ts3-nodejs-library": "^3.4.1",
|
||||
"winston": "^3.8.2"
|
||||
"pino": "^9.6.0",
|
||||
"pino-pretty": "^13.0.0",
|
||||
"ts3-nodejs-library": "^3.4.1"
|
||||
},
|
||||
"name": "ts3gotify",
|
||||
"module": "src/app.ts",
|
||||
|
||||
23
src/app.ts
23
src/app.ts
@@ -4,7 +4,8 @@ import {
|
||||
TeamSpeak,
|
||||
TextMessageTargetMode,
|
||||
} from "ts3-nodejs-library";
|
||||
import { createLogger, transports, format } from "winston";
|
||||
|
||||
import { pino } from "pino";
|
||||
|
||||
import {
|
||||
GOTIFY_TITLE,
|
||||
@@ -21,10 +22,9 @@ import {
|
||||
} from "./env";
|
||||
import type { Mode } from "./types";
|
||||
|
||||
const logger = createLogger({
|
||||
const logger = pino({
|
||||
level: LOG_LEVEL,
|
||||
transports: [new transports.Console()],
|
||||
format: format.combine(format.colorize(), format.timestamp()),
|
||||
name: "ts3gotify",
|
||||
});
|
||||
|
||||
const gotify = new Gotify({
|
||||
@@ -43,15 +43,13 @@ function getModes(): {
|
||||
return { [mode]: true };
|
||||
});
|
||||
|
||||
return Object.assign(
|
||||
{
|
||||
return {
|
||||
connect: false,
|
||||
disconnect: false,
|
||||
moved: false,
|
||||
message: false,
|
||||
},
|
||||
...modes
|
||||
);
|
||||
...modes,
|
||||
};
|
||||
}
|
||||
|
||||
function sendNotification(message: string) {
|
||||
@@ -91,6 +89,13 @@ TeamSpeak.connect({
|
||||
}).then((teamspeak) => {
|
||||
const mode = getModes();
|
||||
|
||||
logger.info(
|
||||
`connected to TS3 in modes: ${Object.entries(mode)
|
||||
.filter(([_, value]) => value)
|
||||
.map(([key]) => key)
|
||||
.join(", ")}`
|
||||
);
|
||||
|
||||
logger.info("connected to TS3");
|
||||
|
||||
if (mode.connect) {
|
||||
|
||||
Reference in New Issue
Block a user