mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 01:29:58 +00:00
Replace remaining console calls with logger calls
This commit is contained in:
@@ -69,10 +69,10 @@ async function getInfo (): Promise<BridgeInfo> {
|
||||
|
||||
// Print compatibility info to console
|
||||
if (!isVersionCompatible) {
|
||||
console.error(`Expecting ${applicationName} v${APPLICATION_VERSION}, found v${applicationVersion}.`
|
||||
, isVersionOlder
|
||||
logger.error(`Expecting ${applicationName} v${APPLICATION_VERSION}, found v${applicationVersion}. ${
|
||||
isVersionOlder
|
||||
? "Try updating the native app to the latest version."
|
||||
: "Try updating the extension to the latest version");
|
||||
: "Try updating the extension to the latest version"}`);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -3,15 +3,30 @@
|
||||
export class Logger {
|
||||
constructor (private prefix: string) {}
|
||||
|
||||
log (message: string) {
|
||||
console.log(`${this.prefix} (Log): ${message}`);
|
||||
log (message: string, data?: any) {
|
||||
const formattedMessage = `${this.prefix} (Log): ${message}`;
|
||||
if (data) {
|
||||
console.log(formattedMessage, data);
|
||||
} else {
|
||||
console.log(formattedMessage);
|
||||
}
|
||||
}
|
||||
debug (message: string) {
|
||||
console.debug(`${this.prefix} (Debug): ${message}`);
|
||||
info (message: string, data?: any) {
|
||||
const formattedMessage = `${this.prefix} (Info): ${message}`;
|
||||
if (data) {
|
||||
console.info(formattedMessage, data);
|
||||
} else {
|
||||
console.info(formattedMessage);
|
||||
}
|
||||
}
|
||||
error (message: string) {
|
||||
error (message: string, data?: any) {
|
||||
const formattedMessage = `${this.prefix} (Error): ${message}`;
|
||||
console.error(formattedMessage);
|
||||
if (data) {
|
||||
console.error(formattedMessage, data);
|
||||
} else {
|
||||
console.error(formattedMessage);
|
||||
}
|
||||
|
||||
return new Error(formattedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
import logger from "./logger";
|
||||
|
||||
const WEBSOCKET_DAEMON_URL = "ws://localhost:9556";
|
||||
|
||||
|
||||
@@ -164,7 +166,7 @@ async function sendNativeMessage (
|
||||
});
|
||||
|
||||
ws.addEventListener("error", () => {
|
||||
console.error("fx_cast (Debug): No bridge application found.");
|
||||
logger.error("No bridge application found.");
|
||||
reject();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user