mirror of
https://github.com/iptv-org/epg
synced 2026-09-09 13:26:55 -04:00
Merge pull request #3197 from tohenk/fix-circular
Prevent circular structure error when logging site configuration.
This commit is contained in:
@@ -134,7 +134,7 @@ async function main() {
|
|||||||
globalConfig.json = options.json
|
globalConfig.json = options.json
|
||||||
if (typeof options.debug === 'boolean') globalConfig.debug = options.debug
|
if (typeof options.debug === 'boolean') globalConfig.debug = options.debug
|
||||||
|
|
||||||
logger.debug(`config: ${JSON.stringify(globalConfig, null, 2)}`)
|
logger.debug(`config: ${JSON.stringify(globalConfig, getCircularReplacer(), 2)}`)
|
||||||
|
|
||||||
const grabber =
|
const grabber =
|
||||||
process.env.NODE_ENV === 'test'
|
process.env.NODE_ENV === 'test'
|
||||||
@@ -143,7 +143,7 @@ async function main() {
|
|||||||
|
|
||||||
grabber.client.instance.interceptors.request.use(
|
grabber.client.instance.interceptors.request.use(
|
||||||
request => {
|
request => {
|
||||||
logger.debug(`request: ${JSON.stringify(request, null, 2)}`)
|
logger.debug(`request: ${JSON.stringify(request, getCircularReplacer(), 2)}`)
|
||||||
|
|
||||||
const curl = globalConfig.curl || defaultConfig.curl
|
const curl = globalConfig.curl || defaultConfig.curl
|
||||||
if (curl) {
|
if (curl) {
|
||||||
@@ -357,3 +357,16 @@ function getLogoForChannel(channel: Channel): string | null {
|
|||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCircularReplacer() {
|
||||||
|
const seen = new WeakSet()
|
||||||
|
return (key: string, value: any) => {
|
||||||
|
if (typeof value === 'object' && value !== null) {
|
||||||
|
if (seen.has(value)) {
|
||||||
|
return '[Circular]'
|
||||||
|
}
|
||||||
|
seen.add(value)
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user