Skip to content

console.log calls from utility process don't work #469

@ThaUnknown

Description

@ThaUnknown

reproduction steps:

import { utilityProcess } from 'electron'
import log from 'electron-log/main'

import forkPath from './background.js?modulePath'

log.initialize({ spyRendererConsole: true })
log.transports.file.level = 'debug'
log.transports.file.maxSize = 10 * 1024 * 1024 // 10MB
autoUpdater.logger = log

const util = utilityProcess.fork(forkPath)

then running any console calls inside background.js won't call logs in electron log

the fix is

const util = utilityProcess.fork(forkPath, [], { stdio: ['ignore', 'pipe', 'pipe'] })

util.stderr?.on('data', d => log.error('' + d))
util.stdout?.on('data', d => log.log('' + d))

expected fix:
read log from electron stdout instead of consolespy? or maybe outline this problem in docs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions