Skip to content

Default Subscriber

Calin P edited this page Nov 2, 2023 · 1 revision

TraceSubscriber

Reference page for the default subscriber provided.

with_level(displayed: bool) -> TraceSubscriber

This method allows you to control whether the trace level (e.g., INFO, DEBUG) is displayed in the captured trace messages.

  • displayed (bool): If set to true, the trace level is displayed in the trace messages; if set to false, the trace level is omitted.
[2023-11-02T12:02:36] INFO src/test.gd::_ready: this is a log
                      ^^^^
[2023-11-02T12:02:36] src/test.gd::_ready: this is a log

with_colored_output(displayed: bool) -> TraceSubscriber

You can use this method to enable or disable colored output for trace messages.

  • displayed (bool): When set to true, colored output is enabled; when set to false, colored output is disabled.

with_module(displayed: bool) -> TraceSubscriber

This method controls whether the module information is displayed in trace messages.

  • displayed (bool): If set to true, the module information is displayed; if set to false, the module information is omitted.
[2023-11-02T12:02:36] INFO src/test.gd::_ready: this is a log
                           ^^^^^^^^^^^
[2023-11-02T12:02:36] INFO _ready: this is a log

with_function(displayed: bool) -> TraceSubscriber

You can use this method to control whether the function information is displayed in the trace messages.

  • displayed (bool): If set to true, the function information is displayed; if set to false, the function information is omitted.
[2023-11-02T12:02:36] INFO src/test.gd::_ready: this is a log
                                        ^^^^^^
[2023-11-02T12:02:36] INFO src/test.gd: this is a log

with_timestamp(displayed: bool) -> TraceSubscriber

This method enables or disables the display of timestamps in trace messages.

  • displayed (bool): When set to true, timestamps are displayed; when set to false, timestamps are omitted.
[2023-11-02T12:02:36] INFO src/test.gd::_ready: this is a log
^^^^^^^^^^^^^^^^^^^^^
INFO src/test.gd::_ready: this is a log

with_thread_id(displayed: bool) -> TraceSubscriber

You can use this method to specify whether the thread ID is displayed in trace messages.

  • displayed (bool): If set to true, the thread ID is displayed; if set to false, the thread ID is omitted.
[2023-11-02T12:02:36] INFO src/test.gd::_ready: this is a log
ThreadId(1) [2023-11-02T12:02:36] INFO src/test.gd::_ready: this is a log
^^^^^^^^^^^

with_nicer_colors(displayed: bool) -> TraceSubscriber

This method controls the use of nicer colors in the output of trace messages. This will make the godot console colors look better but will disable colors for the external shell the editor might be running in.

  • displayed (bool): If set to true, nicer colors are used; if set to false, standard colors are used.

barebones() -> TraceSubscriber

The barebones method provides a shortcut to configure the TraceSubscriber with commonly used settings. It sets the following options:

  • Trace level is displayed.
  • Colored output is disabled.
  • Module and function information is displayed.
  • Timestamps are displayed.
  • Thread ID is omitted.
  • Nicer colors are disabled.

This is useful for writing to files, since you don't want the color codes.

with_writer(writer: Callable) -> TraceSubscriber

This method allows you to set a custom writer function for handling trace messages. You can specify your own writer in the form

func writer(msg: String) -> void:
  • writer (Callable): The custom writer function responsible for processing and outputting trace messages.

The TraceSubscriber class is designed to offer flexibility in customizing how trace messages are displayed and processed, allowing you to adapt the output to your specific debugging and monitoring requirements.