chore(ext): improve debug logging
This commit is contained in:
@@ -10,9 +10,7 @@ export function handlePageControlMessage(
|
|||||||
): true | undefined {
|
): true | undefined {
|
||||||
const PREFIX = '[RemotePageController.background]'
|
const PREFIX = '[RemotePageController.background]'
|
||||||
|
|
||||||
function debug(...messages: any[]) {
|
const debug = console.debug.bind(console, `\x1b[90m${PREFIX}\x1b[0m`)
|
||||||
console.debug(`\x1b[90m${PREFIX}\x1b[0m`, ...messages)
|
|
||||||
}
|
|
||||||
|
|
||||||
const { action, payload, targetTabId } = message
|
const { action, payload, targetTabId } = message
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import type { TabsController } from './TabsController'
|
|||||||
|
|
||||||
const PREFIX = '[RemotePageController]'
|
const PREFIX = '[RemotePageController]'
|
||||||
|
|
||||||
function debug(...messages: any[]) {
|
const debug = console.debug.bind(console, `\x1b[90m${PREFIX}\x1b[0m`)
|
||||||
console.debug(`\x1b[90m${PREFIX}\x1b[0m`, ...messages)
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendMessage(message: {
|
function sendMessage(message: {
|
||||||
type: 'PAGE_CONTROL'
|
type: 'PAGE_CONTROL'
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import type { TabAction } from './TabsController'
|
|||||||
|
|
||||||
const PREFIX = '[TabsController.background]'
|
const PREFIX = '[TabsController.background]'
|
||||||
|
|
||||||
function debug(...messages: any[]) {
|
const debug = console.debug.bind(console, `\x1b[90m${PREFIX}\x1b[0m`)
|
||||||
console.debug(`\x1b[90m${PREFIX}\x1b[0m`, ...messages)
|
const debugError = console.error.bind(console, `\x1b[91m${PREFIX}\x1b[0m`)
|
||||||
}
|
|
||||||
|
|
||||||
export function handleTabControlMessage(
|
export function handleTabControlMessage(
|
||||||
message: { type: 'TAB_CONTROL'; action: TabAction; payload: any },
|
message: { type: 'TAB_CONTROL'; action: TabAction; payload: any },
|
||||||
@@ -141,7 +140,7 @@ export function setupTabChangeEvents() {
|
|||||||
chrome.runtime
|
chrome.runtime
|
||||||
.sendMessage({ type: 'TAB_CHANGE', action: 'created', payload: { tab } })
|
.sendMessage({ type: 'TAB_CHANGE', action: 'created', payload: { tab } })
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
debug('onCreated error:', error)
|
debugError('onCreated error:', error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -154,7 +153,7 @@ export function setupTabChangeEvents() {
|
|||||||
payload: { tabId, removeInfo },
|
payload: { tabId, removeInfo },
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
debug('onRemoved error:', error)
|
debugError('onRemoved error:', error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -167,7 +166,7 @@ export function setupTabChangeEvents() {
|
|||||||
payload: { tabId, changeInfo, tab },
|
payload: { tabId, changeInfo, tab },
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
debug('onUpdated error:', error)
|
debugError('onUpdated error:', error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ import { isContentScriptAllowed } from './RemotePageController'
|
|||||||
|
|
||||||
const PREFIX = '[TabsController]'
|
const PREFIX = '[TabsController]'
|
||||||
|
|
||||||
function debug(...messages: any[]) {
|
const debug = console.debug.bind(console, `\x1b[90m${PREFIX}\x1b[0m`)
|
||||||
console.debug(`\x1b[90m${PREFIX}\x1b[0m`, ...messages)
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendMessage(message: {
|
function sendMessage(message: {
|
||||||
type: 'TAB_CONTROL'
|
type: 'TAB_CONTROL'
|
||||||
|
|||||||
Reference in New Issue
Block a user