mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-02 11:26:46 +02:00
Create BxLogger to show colored logs
This commit is contained in:
27
src/utils/bx-logger.ts
Normal file
27
src/utils/bx-logger.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
enum TextColor {
|
||||
INFO = '#008746',
|
||||
WARNING = '#c1a404',
|
||||
ERROR = '#c10404',
|
||||
}
|
||||
|
||||
export class BxLogger {
|
||||
static #PREFIX = '[BxC]';
|
||||
|
||||
static info(tag: string, ...args: any[]) {
|
||||
BxLogger.#log(TextColor.INFO, tag, ...args);
|
||||
}
|
||||
|
||||
static warning(tag: string, ...args: any[]) {
|
||||
BxLogger.#log(TextColor.WARNING, tag, ...args);
|
||||
}
|
||||
|
||||
static error(tag: string, ...args: any[]) {
|
||||
BxLogger.#log(TextColor.ERROR, tag, ...args);
|
||||
}
|
||||
|
||||
static #log(color: TextColor, tag: string, ...args: any) {
|
||||
console.log('%c' + BxLogger.#PREFIX, 'color:' + color + ';font-weight:bold;', tag, '-', ...args);
|
||||
}
|
||||
}
|
||||
|
||||
(window as any).BxLogger = BxLogger;
|
@@ -2,6 +2,7 @@ import { MkbHandler } from "../modules/mkb/mkb-handler";
|
||||
import { PrefKey, getPref } from "./preferences";
|
||||
import { t } from "./translation";
|
||||
import { Toast } from "./toast";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
|
||||
// Show a toast when connecting/disconecting controller
|
||||
export function showGamepadToast(gamepad: Gamepad) {
|
||||
@@ -10,7 +11,7 @@ export function showGamepadToast(gamepad: Gamepad) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(gamepad);
|
||||
BxLogger.info('Gamepad', gamepad);
|
||||
let text = '🎮';
|
||||
|
||||
if (getPref(PrefKey.LOCAL_CO_OP_ENABLED)) {
|
||||
|
@@ -2,6 +2,7 @@ import { BxEvent } from "./bx-event";
|
||||
import { getPref, PrefKey } from "./preferences";
|
||||
import { STATES } from "./global";
|
||||
import { UserAgent } from "./user-agent";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
|
||||
export function patchVideoApi() {
|
||||
const PREF_SKIP_SPLASH_VIDEO = getPref(PrefKey.SKIP_SPLASH_VIDEO);
|
||||
@@ -77,7 +78,7 @@ export function patchRtcCodecs() {
|
||||
nativeSetCodecPreferences.apply(this, [newCodecs]);
|
||||
} catch (e) {
|
||||
// Didn't work -> use default codecs
|
||||
console.log(e);
|
||||
BxLogger.error('setCodecPreferences', e);
|
||||
nativeSetCodecPreferences.apply(this, [codecs]);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +107,8 @@ export function patchRtcPeerConnection() {
|
||||
if (conn.connectionState === 'connecting') {
|
||||
STATES.currentStream.audioGainNode = null;
|
||||
}
|
||||
console.log('connectionState', conn.connectionState);
|
||||
|
||||
BxLogger.info('connectionstatechange', conn.connectionState);
|
||||
});
|
||||
return conn;
|
||||
}
|
||||
|
Reference in New Issue
Block a user