mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-11 10:09: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 () {
|
function initBrowserAction () {
|
||||||
console.info("fx_cast (Debug): init (browser action)");
|
logger.info("init (browser action)");
|
||||||
|
|
||||||
/*browser.browserAction.disable();
|
/*browser.browserAction.disable();
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ function initBrowserAction () {
|
|||||||
|
|
||||||
|
|
||||||
async function initMenus () {
|
async function initMenus () {
|
||||||
console.info("fx_cast (Debug): init (menus)");
|
logger.info("init (menus)");
|
||||||
|
|
||||||
const URL_PATTERN_HTTP = "http://*/*";
|
const URL_PATTERN_HTTP = "http://*/*";
|
||||||
const URL_PATTERN_HTTPS = "https://*/*";
|
const URL_PATTERN_HTTPS = "https://*/*";
|
||||||
@@ -413,7 +413,7 @@ async function initMenus () {
|
|||||||
|
|
||||||
|
|
||||||
async function initRequestListener () {
|
async function initRequestListener () {
|
||||||
console.info("fx_cast (Debug): init (request listener)");
|
logger.info("init (request listener)");
|
||||||
|
|
||||||
type OnBeforeRequestDetails = Parameters<Parameters<
|
type OnBeforeRequestDetails = Parameters<Parameters<
|
||||||
typeof browser.webRequest.onBeforeRequest.addListener>[0]>[0];
|
typeof browser.webRequest.onBeforeRequest.addListener>[0]>[0];
|
||||||
@@ -457,7 +457,7 @@ async function initRequestListener () {
|
|||||||
|
|
||||||
|
|
||||||
function initWhitelist () {
|
function initWhitelist () {
|
||||||
console.info("fx_cast (Debug): init (whitelist)");
|
logger.info("init (whitelist)");
|
||||||
|
|
||||||
type OnBeforeSendHeadersDetails = Parameters<Parameters<
|
type OnBeforeSendHeadersDetails = Parameters<Parameters<
|
||||||
typeof browser.webRequest.onBeforeSendHeaders.addListener>[0]>[0];
|
typeof browser.webRequest.onBeforeSendHeaders.addListener>[0]>[0];
|
||||||
@@ -536,7 +536,7 @@ function initWhitelist () {
|
|||||||
|
|
||||||
|
|
||||||
async function initMediaOverlay () {
|
async function initMediaOverlay () {
|
||||||
console.info("fx_cast (Debug): init (media overlay)");
|
logger.info("init (media overlay)");
|
||||||
|
|
||||||
let contentScript: browser.contentScripts.RegisteredContentScript;
|
let contentScript: browser.contentScripts.RegisteredContentScript;
|
||||||
|
|
||||||
@@ -553,7 +553,7 @@ async function initMediaOverlay () {
|
|||||||
, runAt: "document_start"
|
, runAt: "document_start"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info("fx_cast (Debug): init");
|
logger.info("init");
|
||||||
|
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import bridge from "../../lib/bridge";
|
import bridge from "../../lib/bridge";
|
||||||
import knownApps from "../../lib/knownApps";
|
import knownApps from "../../lib/knownApps";
|
||||||
|
import logger from "../../lib/logger";
|
||||||
import options from "../../lib/options";
|
import options from "../../lib/options";
|
||||||
|
|
||||||
import { TypedEventTarget } from "../../lib/typedEvents";
|
import { TypedEventTarget } from "../../lib/typedEvents";
|
||||||
@@ -145,8 +146,7 @@ export default class NativeReceiverSelector
|
|||||||
private async onBridgePortMessageError (
|
private async onBridgePortMessageError (
|
||||||
message: NativeReceiverSelectorErrorMessage) {
|
message: NativeReceiverSelectorErrorMessage) {
|
||||||
|
|
||||||
console.error("fx_cast (Debug): Native receiver selector error"
|
logger.error("Native receiver selector error", message.data);
|
||||||
, message.data);
|
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent("error"));
|
this.dispatchEvent(new CustomEvent("error"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ async function getSelection (
|
|||||||
|
|
||||||
availableMediaTypes = getMediaTypesForPageUrl(url);
|
availableMediaTypes = getMediaTypesForPageUrl(url);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("fx_cast (Debug): Failed to locate frame");
|
logger.error("Failed to locate frame");
|
||||||
reject();
|
reject();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -136,25 +136,25 @@ async function getSelection (
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onSelected (ev: any) {
|
function onSelected (ev: any) {
|
||||||
console.info("fx_cast (Debug): Selected receiver", ev.detail);
|
logger.info("Selected receiver", ev.detail);
|
||||||
resolve(ev.detail);
|
resolve(ev.detail);
|
||||||
removeListeners();
|
removeListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCancelled () {
|
function onCancelled () {
|
||||||
console.info("fx_cast (Debug): Cancelled receiver selection");
|
logger.info("Cancelled receiver selection");
|
||||||
resolve(null);
|
resolve(null);
|
||||||
removeListeners();
|
removeListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onError () {
|
function onError () {
|
||||||
console.error("fx_cast (Debug): Failed to select receiver");
|
logger.error("Failed to select receiver");
|
||||||
reject();
|
reject();
|
||||||
removeListeners();
|
removeListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onStop (ev: any) {
|
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.init().then(() => {
|
||||||
StatusManager.stopReceiverApp(ev.detail.receiver);
|
StatusManager.stopReceiverApp(ev.detail.receiver);
|
||||||
|
|||||||
@@ -69,10 +69,10 @@ async function getInfo (): Promise<BridgeInfo> {
|
|||||||
|
|
||||||
// Print compatibility info to console
|
// Print compatibility info to console
|
||||||
if (!isVersionCompatible) {
|
if (!isVersionCompatible) {
|
||||||
console.error(`Expecting ${applicationName} v${APPLICATION_VERSION}, found v${applicationVersion}.`
|
logger.error(`Expecting ${applicationName} v${APPLICATION_VERSION}, found v${applicationVersion}. ${
|
||||||
, isVersionOlder
|
isVersionOlder
|
||||||
? "Try updating the native app to the latest version."
|
? "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 {
|
return {
|
||||||
|
|||||||
@@ -3,15 +3,30 @@
|
|||||||
export class Logger {
|
export class Logger {
|
||||||
constructor (private prefix: string) {}
|
constructor (private prefix: string) {}
|
||||||
|
|
||||||
log (message: string) {
|
log (message: string, data?: any) {
|
||||||
console.log(`${this.prefix} (Log): ${message}`);
|
const formattedMessage = `${this.prefix} (Log): ${message}`;
|
||||||
|
if (data) {
|
||||||
|
console.log(formattedMessage, data);
|
||||||
|
} else {
|
||||||
|
console.log(formattedMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
debug (message: string) {
|
info (message: string, data?: any) {
|
||||||
console.debug(`${this.prefix} (Debug): ${message}`);
|
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}`;
|
const formattedMessage = `${this.prefix} (Error): ${message}`;
|
||||||
console.error(formattedMessage);
|
if (data) {
|
||||||
|
console.error(formattedMessage, data);
|
||||||
|
} else {
|
||||||
|
console.error(formattedMessage);
|
||||||
|
}
|
||||||
|
|
||||||
return new Error(formattedMessage);
|
return new Error(formattedMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
import logger from "./logger";
|
||||||
|
|
||||||
const WEBSOCKET_DAEMON_URL = "ws://localhost:9556";
|
const WEBSOCKET_DAEMON_URL = "ws://localhost:9556";
|
||||||
|
|
||||||
|
|
||||||
@@ -164,7 +166,7 @@ async function sendNativeMessage (
|
|||||||
});
|
});
|
||||||
|
|
||||||
ws.addEventListener("error", () => {
|
ws.addEventListener("error", () => {
|
||||||
console.error("fx_cast (Debug): No bridge application found.");
|
logger.error("No bridge application found.");
|
||||||
reject();
|
reject();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
import logger from "../../../lib/logger";
|
||||||
|
|
||||||
import { bindPropertyDescriptor
|
import { bindPropertyDescriptor
|
||||||
, clonePropsDescriptor
|
, clonePropsDescriptor
|
||||||
, getPropertyDescriptor
|
, getPropertyDescriptor
|
||||||
@@ -299,7 +301,7 @@ function wrapMediaElement (mediaElement: HTMLMediaElement) {
|
|||||||
const shadowRoot = internalShadowRoots.get(wrappedMedia);
|
const shadowRoot = internalShadowRoots.get(wrappedMedia);
|
||||||
|
|
||||||
if (!shadowRoot) {
|
if (!shadowRoot) {
|
||||||
console.error("err: Failed to fetch shadow root!");
|
logger.error("Failed to fetch shadow root!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +331,7 @@ function wrapMediaElement (mediaElement: HTMLMediaElement) {
|
|||||||
for (const source of mediaElement.getElementsByTagName("source")) {
|
for (const source of mediaElement.getElementsByTagName("source")) {
|
||||||
const internalMedia = shadowRoot.querySelector("audio,video");
|
const internalMedia = shadowRoot.querySelector("audio,video");
|
||||||
if (!internalMedia) {
|
if (!internalMedia) {
|
||||||
console.error("err: Failed to fetch internal video element!");
|
logger.error("Failed to fetch internal video element!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ class OptionsApp extends Component<{}, OptionsAppState> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to save options");
|
logger.error("Failed to save options");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user