mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-08 08:39:59 +00:00
Replace remaining console calls with logger calls
This commit is contained in:
@@ -45,7 +45,7 @@ browser.runtime.onInstalled.addListener(async details => {
|
||||
|
||||
|
||||
function initBrowserAction () {
|
||||
console.info("fx_cast (Debug): init (browser action)");
|
||||
logger.info("init (browser action)");
|
||||
|
||||
/*browser.browserAction.disable();
|
||||
|
||||
@@ -86,7 +86,7 @@ function initBrowserAction () {
|
||||
|
||||
|
||||
async function initMenus () {
|
||||
console.info("fx_cast (Debug): init (menus)");
|
||||
logger.info("init (menus)");
|
||||
|
||||
const URL_PATTERN_HTTP = "http://*/*";
|
||||
const URL_PATTERN_HTTPS = "https://*/*";
|
||||
@@ -413,7 +413,7 @@ async function initMenus () {
|
||||
|
||||
|
||||
async function initRequestListener () {
|
||||
console.info("fx_cast (Debug): init (request listener)");
|
||||
logger.info("init (request listener)");
|
||||
|
||||
type OnBeforeRequestDetails = Parameters<Parameters<
|
||||
typeof browser.webRequest.onBeforeRequest.addListener>[0]>[0];
|
||||
@@ -457,7 +457,7 @@ async function initRequestListener () {
|
||||
|
||||
|
||||
function initWhitelist () {
|
||||
console.info("fx_cast (Debug): init (whitelist)");
|
||||
logger.info("init (whitelist)");
|
||||
|
||||
type OnBeforeSendHeadersDetails = Parameters<Parameters<
|
||||
typeof browser.webRequest.onBeforeSendHeaders.addListener>[0]>[0];
|
||||
@@ -536,7 +536,7 @@ function initWhitelist () {
|
||||
|
||||
|
||||
async function initMediaOverlay () {
|
||||
console.info("fx_cast (Debug): init (media overlay)");
|
||||
logger.info("init (media overlay)");
|
||||
|
||||
let contentScript: browser.contentScripts.RegisteredContentScript;
|
||||
|
||||
@@ -553,7 +553,7 @@ async function initMediaOverlay () {
|
||||
, runAt: "document_start"
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("fx_cast (Debug): Failed to register media overlay");
|
||||
logger.error("Failed to register media overlay")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ async function init () {
|
||||
return;
|
||||
}
|
||||
|
||||
console.info("fx_cast (Debug): init");
|
||||
logger.info("init");
|
||||
|
||||
isInitialized = true;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import bridge from "../../lib/bridge";
|
||||
import knownApps from "../../lib/knownApps";
|
||||
import logger from "../../lib/logger";
|
||||
import options from "../../lib/options";
|
||||
|
||||
import { TypedEventTarget } from "../../lib/typedEvents";
|
||||
@@ -145,8 +146,7 @@ export default class NativeReceiverSelector
|
||||
private async onBridgePortMessageError (
|
||||
message: NativeReceiverSelectorErrorMessage) {
|
||||
|
||||
console.error("fx_cast (Debug): Native receiver selector error"
|
||||
, message.data);
|
||||
logger.error("Native receiver selector error", message.data);
|
||||
|
||||
this.dispatchEvent(new CustomEvent("error"));
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ async function getSelection (
|
||||
|
||||
availableMediaTypes = getMediaTypesForPageUrl(url);
|
||||
} catch (err) {
|
||||
console.error("fx_cast (Debug): Failed to locate frame");
|
||||
logger.error("Failed to locate frame");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
@@ -136,25 +136,25 @@ async function getSelection (
|
||||
}
|
||||
|
||||
function onSelected (ev: any) {
|
||||
console.info("fx_cast (Debug): Selected receiver", ev.detail);
|
||||
logger.info("Selected receiver", ev.detail);
|
||||
resolve(ev.detail);
|
||||
removeListeners();
|
||||
}
|
||||
|
||||
function onCancelled () {
|
||||
console.info("fx_cast (Debug): Cancelled receiver selection");
|
||||
logger.info("Cancelled receiver selection");
|
||||
resolve(null);
|
||||
removeListeners();
|
||||
}
|
||||
|
||||
function onError () {
|
||||
console.error("fx_cast (Debug): Failed to select receiver");
|
||||
logger.error("Failed to select receiver");
|
||||
reject();
|
||||
removeListeners();
|
||||
}
|
||||
|
||||
function onStop (ev: any) {
|
||||
console.info("fx_cast (Debug): Stopped receiver app", ev.detail);
|
||||
logger.info("Stopped receiver app", ev.detail);
|
||||
|
||||
StatusManager.init().then(() => {
|
||||
StatusManager.stopReceiverApp(ev.detail.receiver);
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
import logger from "../../../lib/logger";
|
||||
|
||||
import { bindPropertyDescriptor
|
||||
, clonePropsDescriptor
|
||||
, getPropertyDescriptor
|
||||
@@ -299,7 +301,7 @@ function wrapMediaElement (mediaElement: HTMLMediaElement) {
|
||||
const shadowRoot = internalShadowRoots.get(wrappedMedia);
|
||||
|
||||
if (!shadowRoot) {
|
||||
console.error("err: Failed to fetch shadow root!");
|
||||
logger.error("Failed to fetch shadow root!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -329,7 +331,7 @@ function wrapMediaElement (mediaElement: HTMLMediaElement) {
|
||||
for (const source of mediaElement.getElementsByTagName("source")) {
|
||||
const internalMedia = shadowRoot.querySelector("audio,video");
|
||||
if (!internalMedia) {
|
||||
console.error("err: Failed to fetch internal video element!");
|
||||
logger.error("Failed to fetch internal video element!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -422,7 +422,7 @@ class OptionsApp extends Component<{}, OptionsAppState> {
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to save options");
|
||||
logger.error("Failed to save options");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user