Skip to content

Commit bf0fb5a

Browse files
authored
Merge pull request #10812 from Calinou/data-paths-file-logging
Document file logging in Data paths
2 parents 58578cb + d430550 commit bf0fb5a

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

contributing/development/compiling/introduction_to_the_buildsystem.rst

+2
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ binary name.
197197
you can enable at compile-time to better debug certain engine issues.
198198
See :ref:`doc_using_sanitizers` for more information.
199199

200+
.. _doc_introduction_to_the_buildsystem_debugging_symbols:
201+
200202
Debugging symbols
201203
-----------------
202204

tutorials/export/exporting_for_dedicated_servers.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@ On Linux, to make your dedicated server restart after a crash or system reboot,
281281
you can
282282
`create a systemd service <https://medium.com/@benmorel/creating-a-linux-service-with-systemd-611b5c8b91d6>`__.
283283
This also lets you view server logs in a more convenient fashion, with automatic
284-
log rotation provided by systemd.
284+
log rotation provided by systemd. When making your project hostable as a systemd service,
285+
you should also enable the ``application/run/flush_stdout_on_print``
286+
project setting. This way, journald (the systemd logging service) can collect
287+
logs while the process is running.
285288

286289
If you have experience with containers, you could also look into wrapping your
287290
dedicated server in a `Docker <https://www.docker.com/>`__ container. This way,

tutorials/io/data_paths.rst

+42
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,48 @@ On HTML5 exports, ``user://`` will refer to a virtual filesystem stored on the
111111
device via IndexedDB. (Interaction with the main filesystem can still be performed
112112
through the :ref:`JavaScriptBridge <class_JavaScriptBridge>` singleton.)
113113

114+
File logging
115+
------------
116+
117+
By default, Godot writes log files in ``user://logs/godot.log`` on desktop
118+
platforms. You can change this location by modifying the
119+
``debug/file_logging/log_path`` project setting. Logs are rotated to keep older
120+
files available for inspection. Each session creates a new log file, with the
121+
old file renamed to contain the date at which it was rotated. Up to 5 log files
122+
are kept by default, which can be adjusted using the
123+
``debug/file_logging/max_log_files`` project setting.
124+
125+
File logging can also be disabled completely using the
126+
``debug/file_logging/enable_file_logging`` project setting.
127+
128+
When the project crashes, crash logs are written to the same file as the log
129+
file. The crash log will only contain an usable backtrace if the binary that was
130+
run contains debugging symbols, or if it can find a debug symbols file that
131+
matches the binary. Official binaries don't provide debugging symbols, so this
132+
requires a custom build to work. See
133+
:ref:`Debugging symbols <doc_introduction_to_the_buildsystem_debugging_symbols>`.
134+
for guidance on compiling binaries with debugging symbols enabled.
135+
136+
.. note::
137+
138+
Log files for :ref:`print<class_@GlobalScope_method_print>`
139+
statements are updated when standard output is *flushed* by the engine.
140+
Standard output is flushed on every print in debug builds only. In projects that
141+
are exported in release mode, standard output is only flushed when the project exits
142+
or crashes to improve performance, especially if the project is often printing
143+
text to standard output.
144+
145+
On the other hand, the standard error stream
146+
(used by :ref:`printerr<class_@GlobalScope_method_printerr>`,
147+
:ref:`push_error<class_@GlobalScope_method_push_error>` and
148+
:ref:`push_warning<class_@GlobalScope_method_push_warning>`) is always
149+
flushed on every print, even in projects exported in release mode.
150+
151+
For some use cases like dedicated servers, it can be preferred to have release
152+
builds always flush stdout on print, so that logging services like journald can
153+
collect logs while the process is running. This can be done by enabling
154+
``application/run/flush_stdout_on_print`` in the Project Settings.
155+
114156
Converting paths to absolute paths or "local" paths
115157
---------------------------------------------------
116158

0 commit comments

Comments
 (0)