Skip to content

Commit

Permalink
fix: use enable from @libp2p/logger (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki authored Oct 24, 2024
1 parent ade0074 commit cb8c662
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 282 deletions.
260 changes: 3 additions & 257 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"@libp2p/logger": "^4.0.10",
"@multiformats/dns": "^1.0.6",
"@sgtpooki/file-type": "^1.0.1",
"debug": "^4.3.4",
"ipfs-css": "^1.4.0",
"multiformats": "^13.1.0",
"react": "^18.3.0",
Expand Down
9 changes: 4 additions & 5 deletions src/lib/config-db.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import debugLib from 'debug'
import { type ComponentLogger, enable } from '@libp2p/logger'
import { GenericIDB, type BaseDbConfig } from './generic-db.js'
import { LOCAL_STORAGE_KEYS } from './local-storage.js'
import type { ComponentLogger } from '@libp2p/logger'

export interface ConfigDb extends BaseDbConfig {
gateways: string[]
Expand Down Expand Up @@ -31,7 +30,7 @@ export async function loadConfigFromLocalStorage (): Promise<void> {
const gateways = JSON.parse(localStorageGatewaysString)
const routers = JSON.parse(localStorageRoutersString)
const dnsJsonResolvers = JSON.parse(localStorageDnsResolvers)
debugLib.enable(debug)
enable(debug)

await configDb.put('gateways', gateways)
await configDb.put('routers', routers)
Expand Down Expand Up @@ -59,7 +58,7 @@ export async function resetConfig (): Promise<void> {

export async function setConfig (config: ConfigDb, logger: ComponentLogger): Promise<void> {
const log = logger.forComponent('set-config')
debugLib.enable(config.debug ?? '') // set debug level first.
enable(config.debug ?? '') // set debug level first.
log('config-debug: setting config %O for domain %s', config, window.location.origin)

await configDb.open()
Expand Down Expand Up @@ -91,7 +90,7 @@ export async function getConfig (logger: ComponentLogger): Promise<ConfigDb> {
autoReload = await configDb.get('autoReload') ?? false
debug = await configDb.get('debug') ?? ''
configDb.close()
debugLib.enable(debug)
enable(debug)
} catch (err) {
log('error loading config from db', err)
}
Expand Down
Loading

0 comments on commit cb8c662

Please sign in to comment.