mirror of
https://github.com/DerTyp7/teamspeak-obs-overlay.git
synced 2025-10-29 21:02:10 +01:00
[feature] created Logger
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { IAuthSenderPayload, IChannel, IClient, IConnection, ITS5ConnectionHandler, ITS5DataHandler, ITS5MessageHandler } from "@interfaces/teamspeak";
|
import { IAuthSenderPayload, IChannel, IClient, IConnection, ITS5ConnectionHandler, ITS5DataHandler, ITS5MessageHandler } from "@interfaces/teamspeak";
|
||||||
import { TS5DataHandler } from "./dataHandler";
|
import { TS5DataHandler } from "./dataHandler";
|
||||||
import { TS5MessageHandler } from "./messageHandler";
|
import { TS5MessageHandler } from "./messageHandler";
|
||||||
|
import Logger from "@/utils/logger";
|
||||||
|
|
||||||
|
|
||||||
// Establish connection to TS5 client
|
// Establish connection to TS5 client
|
||||||
@@ -22,6 +23,8 @@ export class TS5ConnectionHandler implements ITS5ConnectionHandler {
|
|||||||
setClients: React.Dispatch<React.SetStateAction<IClient[]>>,
|
setClients: React.Dispatch<React.SetStateAction<IClient[]>>,
|
||||||
setActiveConnectionStateId: React.Dispatch<React.SetStateAction<number>>,
|
setActiveConnectionStateId: React.Dispatch<React.SetStateAction<number>>,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
// Create websocket connection to TS5 client
|
// Create websocket connection to TS5 client
|
||||||
this.remoteAppPort = remoteAppPort;
|
this.remoteAppPort = remoteAppPort;
|
||||||
this.ws = new WebSocket(`ws://localhost:${this.remoteAppPort}`);
|
this.ws = new WebSocket(`ws://localhost:${this.remoteAppPort}`);
|
||||||
|
|||||||
31
src/utils/logger.tsx
Normal file
31
src/utils/logger.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
export default class Logger {
|
||||||
|
// Log message to the console
|
||||||
|
public static log(message: string): void {
|
||||||
|
console.log(`%c${message}`, "color: gray");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log warning to the console
|
||||||
|
public static warn(message: string): void {
|
||||||
|
console.warn(`%c${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log error to the console
|
||||||
|
public static error(message: string): void {
|
||||||
|
console.error(`%c${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log message received from the websocket to the console
|
||||||
|
public static wsRecieved(wsData: object): void {
|
||||||
|
console.log(`%c[WS Recieved]`, "color: #683dad", wsData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log message sent to the websocket to the console
|
||||||
|
public static wsSent(wsData: object): void {
|
||||||
|
console.log(`%c[WS Sent]`, "color: #4eb570", wsData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log message to the console with a timestamp
|
||||||
|
public static ts(message: string): void {
|
||||||
|
console.log(`%c[TS] ${message}`, "color: #2e6bc7");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user