Merge pull request #683 from shocknet/fix-logger2

log component name
This commit is contained in:
Justin (shocknet) 2024-05-07 11:09:09 -04:00 committed by GitHub
commit a8e2a2114d
4 changed files with 18 additions and 4 deletions

View file

@ -78,6 +78,12 @@ export const getLogger = (params: LoggerParams): PubLogger => {
}
toLog.push(params.appName)
}
if (params.component) {
if (disabledComponents.includes(params.component)) {
return
}
toLog.push(params.component)
}
if (params.userId) {
toLog.push(params.userId)
}
@ -87,7 +93,13 @@ export const getLogger = (params: LoggerParams): PubLogger => {
writers.forEach(w => w(final))
}
}
const disabledApps: string[] = []
export const disableLoggers = (appNamesToDisable: string[]) => {
disabledApps.push(...appNamesToDisable)
let disabledApps: string[] = []
let disabledComponents: string[] = []
export const resetDisabledLoggers = () => {
disabledApps = []
disabledComponents = []
}
export const disableLoggers = (appNamesToDisable: string[], componentsToDisable: string[]) => {
disabledApps.push(...appNamesToDisable)
disabledComponents.push(...componentsToDisable)
}

View file

@ -4,7 +4,7 @@ import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalan
export const ignore = false
export default async (T: TestBase) => {
disableLoggers(["EventsLogManager", "htlcTracker", "watchdog"])
disableLoggers([], ["EventsLogManager", "htlcTracker", "watchdog"])
await safelySetUserBalance(T, T.user1, 2000)
await testSpamExternalPayment(T)
await runSanityCheck(T)

View file

@ -5,7 +5,7 @@ import * as Types from '../../proto/autogenerated/ts/types.js'
export const ignore = false
export default async (T: TestBase) => {
disableLoggers(["EventsLogManager", "htlcTracker", "watchdog"])
disableLoggers([], ["EventsLogManager", "htlcTracker", "watchdog"])
await safelySetUserBalance(T, T.user1, 2000)
await testSpamExternalPayment(T)
await runSanityCheck(T)

View file

@ -9,6 +9,7 @@ import chaiString from 'chai-string'
import { defaultInvoiceExpiry } from '../services/storage/paymentStorage.js'
import SanityChecker from '../services/main/sanityChecker.js'
import LND from '../services/lnd/lnd.js'
import { resetDisabledLoggers } from '../services/helpers/logger.js'
chai.use(chaiString)
export const expect = chai.expect
export type Describe = (message: string, failure?: boolean) => void
@ -69,6 +70,7 @@ export const teardown = async (T: TestBase) => {
T.externalAccessToMainLnd.Stop()
T.externalAccessToOtherLnd.Stop()
T.externalAccessToThirdLnd.Stop()
resetDisabledLoggers()
console.log("teardown")
}