Skip to content
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

print() to log text, does not appear from exported app, until after it is closed. #33253

Closed
wyattbiker opened this issue Nov 2, 2019 · 10 comments

Comments

@wyattbiker
Copy link

wyattbiker commented Nov 2, 2019

Godot version:
Any

OS/device including version:
Any

Issue description:
print() to log file will not show the output until after the app is closed. This only happens when the executable is exported with Export With Debug flag unchecked.

Steps to reproduce:
Put this code in _ready() of a node script.

extends Node

func _ready():
	for i in range(100):
		print("i=%d" % i)

Make sure you have enabled logging in Project Settings.
image

  • Export Project but uncheck Export With Debug flag before Save To File dialog.
  • Run the exported app.
  • View the log.txt in Project Data Folder while the app main window is still open/running. Path can be found using the following menu option:
    image
  • Notice, no print output is written.
  • Now close app.
  • View log again.
  • This time, the print output result is written.

Somehow it is not flushing output while app is running. This is not good if you are monitoring log output of an app.

@KoBeWi
Copy link
Member

KoBeWi commented Nov 3, 2019

Flushing causes overhead, so it makes sense that it happens only once if you disable debug, no?

@wyattbiker
Copy link
Author

No it does not make sense. If you are printing to logs then it should show up in the logs. The programmer decides if he wants it or not.

@Calinou
Copy link
Member

Calinou commented Nov 3, 2019

I wonder if this is related to #33255 somehow. See also #2233 (comment). While those issues are about printraw(), I suppose the underlying issue is similar.

@wyattbiker
Copy link
Author

I wonder if this is related to #33255 somehow. See also #2233 (comment). While those issues are about printraw(), I suppose the underlying issue is similar.

printerr() works fine but also flushes out print() output if it comes after. So in some respects it can be a workaround for flush.

@sulai
Copy link

sulai commented Jun 11, 2020

I deployed a server using Godot, which crashes due to an unknown event. Because there is nothing written to the log files, there is no chance to fix anything. I'm not sure if this is the same issue as discussed here. I tick "Enable File Logging" just as explained in the original post. The logs/log.txt file stays empty (0 Byte). I tried:

  • 3 different linux machines
  • debug and release versions
  • rename log.txt to server.log
  • delete all logs and let them re-create
  • run in godot editor and headless-server

The log files stay empty. I have no idea how to fix that.

@KoBeWi
Copy link
Member

KoBeWi commented Jun 11, 2020

^
That sounds like a different issue.

@wyattbiker
Copy link
Author

See if this article adds anything to help https://medium.com/@silocoder/using-log-files-to-debug-godot-game-engine-apps-14c191df6580

Also I am wondering if reading a log file will force it to be flushed.

@Calinou
Copy link
Member

Calinou commented Jun 12, 2020

Also I am wondering if reading a log file will force it to be flushed.

Probably not; Godot handles when it should flush the standard output/error stream.

@sulai
Copy link

sulai commented Jun 12, 2020

@wyattbiker I read this before, no luck.

I ended up using a pipe to write the printed output to a file...

@Calinou
Copy link
Member

Calinou commented Dec 24, 2020

This was implemented by #44393, closing.

@Calinou Calinou closed this as completed Dec 24, 2020
@Calinou Calinou added this to the 4.0 milestone Dec 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants