Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use enable from @libp2p/logger #398

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading