Skip to content

Commit

Permalink
build: silence logs on beta build
Browse files Browse the repository at this point in the history
  • Loading branch information
xstelea committed Dec 15, 2022
1 parent fc31d30 commit ef17260
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .env.beta
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_APP_SIGNALING_SERVER_BASE_URL=wss://signaling-server-betanet.radixdlt.com
VITE_APP_LOG_LEVEL=debug
VITE_APP_LOG_LEVEL=info
14 changes: 12 additions & 2 deletions src/chrome/chrome-connector-client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Connector, ConnectorType } from 'connector/connector'
import { StorageClient } from 'connector/storage/storage-client'
import { config } from 'config'
import { LogLevelDesc } from 'loglevel'
import log, { LogLevelDesc } from 'loglevel'
import { map, Subscription } from 'rxjs'
import { ChromeDAppClient } from './chrome-dapp-client'

Expand All @@ -10,10 +10,20 @@ const chromeDAppClient = ChromeDAppClient()
export const ChromeConnectorClient = (logLevel: LogLevelDesc) => {
let connector: ConnectorType | undefined
let subscriptions: Subscription | undefined
const logger = log

chrome.storage.local.get('loglevel').then((value) => {
const storedLoglevel = value['loglevel']

if (storedLoglevel === 'DEBUG')
console.log(`Radix Connector loglevel: 'debug'`)

logger.setLevel(storedLoglevel || logLevel)
})

const createConnector = () => {
connector = Connector({
logLevel,
logger,
storageClient: StorageClient({ id: config.storage.key }),
generateConnectionPassword: false,
})
Expand Down
27 changes: 18 additions & 9 deletions src/chrome/content.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import { config } from 'config'
import { ChromeConnectorClient } from './chrome-connector-client'
import { ChromeDAppClient, messageLifeCycleEvent } from './chrome-dapp-client'
import { decorateMessage } from './helpers/decorate-message'

const connectorClient = ChromeConnectorClient('debug')
const connectorClient = ChromeConnectorClient(config.logLevel)
const chromeDAppClient = ChromeDAppClient()

chromeDAppClient.messageListener((message) => {
decorateMessage(message)
.map(connectorClient.getConnector().sendMessage)
.map(chrome.runtime.sendMessage)
.andThen(() =>
chromeDAppClient.sendMessageEvent(
message.requestId,
messageLifeCycleEvent.receivedByExtension
)
if (message.type === 'debugMode') {
const loglevel = message.value ? 'DEBUG' : 'INFO'
console.log(
`🛠 Setting loglevel to: ${loglevel}, reload the window for effects to take place`
)
chrome.storage.local.set({ loglevel })
} else {
decorateMessage(message)
.map(connectorClient.getConnector().sendMessage)
.map(chrome.runtime.sendMessage)
.andThen(() =>
chromeDAppClient.sendMessageEvent(
message.requestId,
messageLifeCycleEvent.receivedByExtension
)
)
}
})

0 comments on commit ef17260

Please sign in to comment.