-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use separate logger for ui/sw (#217)
* chore: use prefixLogger * chore: use new logger in sw.ts * fix: use separate logger for ui/sw * chore: fix self-reviewed issues * chore: shorten debug log prefix
- Loading branch information
Showing
9 changed files
with
82 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import { logger } from '@libp2p/logger' | ||
import { prefixLogger, type ComponentLogger } from '@libp2p/logger' | ||
|
||
const logObj = logger('helia:service-worker-gateway') | ||
const host = globalThis.location.host.replace(':', '_') | ||
|
||
export const log = logObj | ||
export const error = logObj.error | ||
export const trace = logObj.trace | ||
const swLogPrefix = `helia:sw-gateway:sw:${host}` | ||
const uiLogPrefix = `helia:sw-gateway:ui:${host}` | ||
|
||
export const swLogger = prefixLogger(swLogPrefix) | ||
export const uiLogger = prefixLogger(uiLogPrefix) | ||
|
||
export const getUiComponentLogger = (component: string): ComponentLogger => { | ||
return prefixLogger(`${uiLogPrefix}:${component}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.