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
console.log does not log to the dev tools console window #11990
Comments
"dev tools" is referring to the external chrome dev tools inspecting/debugging the electron main process. |
+1, seeing this as of 2.0, wasn't happening in 1.8. |
On windows, console.log is redirected to process.log if (process.platform === 'win32') {
// Redirect node's console to use our own implementations, since node can not
// handle console output when running as GUI program.
var consoleLog = function (...args) {
return process.log(util.format(...args) + '\n')
} which is implemented in AtomBindings::Log #if defined(OS_WIN)
process.SetMethod("log", &AtomBindings::Log);
#endif which only logs to stdout // static
void AtomBindings::Log(const base::string16& message) {
std::cout << message << std::flush;
} so can't the new console.log simply call both, the orginal console.log and process.log? if (process.platform === 'win32') {
// Redirect node's console to use our own implementations, since node can not
// handle console output when running as GUI program.
const origLog = console.log
var consoleLog = function (...args) {
origLog.call(console, ...args);
return process.log(util.format(...args) + '\n')
} |
@bughit The problem with original implementation is, it would throw exception when stdout is not available. We should probably find out which call is actually printing the message to devtools and then invoke it. |
@zcbenz I actually got around to trying my suggestion a while ago and saw that it was double logging, though I did not see exceptions, should have posted that. |
This is painful, how are people debugging electron apps without repl working? Any workarounds? I tested in 1.8.8 and it's broken there too. It was working at some point, anyone know a version? Edit: On OS X Mojave, tried 1.8.8, 2.0 latest and 3.0 latest beta. |
I have never experience this until today. What a weird behaviour :/ |
Any update on this? Is there any workaround? |
Thank you for taking the time to report this issue and helping to make Electron better. The version of Electron you reported this on has been superseded by newer releases. If you're still experiencing this issue in Electron v4.2.x or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know. I'm setting the Thanks in advance! Your help is appreciated. |
Still happens on 6 and 5 for me.
|
It's also still not working on version 6 for me, bug seems obvious and is easy to replicate. Update: I only see the Windows label, to clarify it also does not work on Linux distributions. |
@sofianguy Does the author of the bug need to reply to clear this need-info? Yes, it's still present in 6. |
I can confirm this is happening in v6.0.x (namely v6.0.7) on Windows 10 (1809). It also appears to not happen to For example: // index.js
console.log('log')
console.info('info')
Serves as a work-around I guess, but still annoying. |
Same. Electron version v8.2.5, Win7 64.
|
I'm on v11.1.1 and the issue is still here. |
Can confirm this issue is still here, but only on Windows for me, not on Linux. I can log nothing in the browser, no matter what I try with console.log, console.info, using '' instead of ``, the only thing that can log something for me on Windows is myConsole that logs in the nodejs process, but that's not what I want. |
Expected behavior
node --inspect-brk -e console.log('hello')
logs to stdout and the dev tools consoleso one expects electron to do the same
Actual behavior
electron with attached dev tools only logs to stdout
How to reproduce
console_log.js
withconsole.log('hello');
electron.exe --inspect-brk console_log.js
The text was updated successfully, but these errors were encountered: