Close

Experimental:Palette:logger

Summary

Starting with the first build released publicly on the 2023.10k branch, TouchDesigner now comes with its own Logger COMP.

For more details about logging in TouchDesigner, please visit the Logger page.

The Logger COMP is a wrapper around the Python Logging Library, and comes as an interface to add additional Loggers easily in your TouchDesigner projects, while relying (or not) on the TDAppLogger internally shipping with TouchDesigner.

Logging can come at a performance cost when used inefficiently. Users should visit this page which applies to TouchDesigner as well.

The easiest way to use the Logger COMP within your own components is by drag n dropping a Logger COMP in your custom component and by referencing the Logger COMP as a COMP Parameter to be used internally, or better, by assigning the Logger COMP to a member in a custom python extension.

From within your scripts, you can call logger.Error('Some Error Message'), logger.Warning('Some Warning Message')… etc.

See the Logger Extension page to have a list of exposed members and methods.

By default, the Logger COMP will be parented to an internal Logger that comes shipped with TouchDesigner, named TDAppLogger.

For general purpose logging, users don’t have to use a new Logger COMP, you can simply use the TDAppLogger by accessing it using op.TDResources.TDAppLogger. Again, refer to the Logger extension page to get a better idea of which members and methods are exposed.

If you rather have a more custom approach, or rely on the hierarchical structure of the Python logging library, then use the Logger COMP.

Note that when tuning the Logger COMP parameters, it will often occur that a logger instance (read, the Python logger object) gets destroyed and re-created. Similarly, some Python logging handlers might be destroyed and re-created to follow the new Logger COMP parameters.

Since builds 2023.31600+, the Logger COMP, v2.6.2+, is always initializing a Logger object (from the logging library: logging.Logger). This is to avoid initialization issues where a Logger might be missing although part of the user network needs to log messages. Additionally, to assist the new Thread Manager coming in builds 2023.30k+ a QueueHandler is available at all time. The QueueHandler is the main handler on the Logger COMP, receiving log messages to be dispatched to additional handlers. Two base handlers are supported, a StreamHandler routing messages to the Textport, as well as a TimedRotatingFileHandler, logging messages to log files. New features are exposed for users to add their own handlers which will also get messages dispatched from the QueueHandler. See the Logger Extension page for details.

If you are actively logging messages while tweaking those parameters, issues might occur. While not necessary for all cases, it is advised to turn off the Active parameter first.

For advanced Python users, the actual Python Logger object is exposed via the loggerCOMP.Logger member.

PythonIcon.pngPalette:logger Ext


Parameters - Settings Page

Active Active - When the active flag is turned off, most logging messages will be silenced and log levels are ignored.

Parent Logger Parentlogger - The Logger COMP to which this Logger COMP is currently parented. Parenting allow for logging messages to be passed up to any handler associated with a parent. When using parenting, it is possible to see duplicates records in the textport if the records are being propagated as well as being logged to textport.

Propagate to parent(s) Propagate - When using parenting, use this toggle if you wish to prevent messages from being passed to the parent.

Open Parameters Dialog Openparametersdialog - Open a floating window of the parameters dialog.

General Settings Generalsettings -

Origin Origin - Reference a COMP for the logger to mention where the log messages are originating from.

Log Level Loglevel - - Filter level of logging messages. The selected level is included as well as all levels above. I.e. if Warning is selected, Warning and Error messages will be included while Info messages will be excluded.
  • INFO INFO -
  • DEBUG DEBUG -
  • WARNING WARNING -
  • ERROR ERROR -
  • CRITICAL CRITICAL -
Log App Errors (from Error DAT) Logapperrors - Use an internal Error DAT which filters any messages matching the Origin and Log Level.

Log to Textport Logtotextport - When enabled, logging messages will be displayed in the textport.

Log to Status Bar Logtostatusbar - When enabled, logging messages will be displayed in the status bar.

File Logger Settings Fileloggersettings -

Logger Name Loggername - The name of the Logger instance. This is reflected in the logging messages when multiple loggers are passing messages to a parent and being processed by the same handler.

Log to File Logtofile - When enabled, logging messages will be written to a time rotated log file.

Log Folder Logfolder - Path to the folder in which the log files should be written.

Open Log Folder Openlogfolder - Open the folder to which the .log file is present. The folder opened isn't necesarily the folder set in the Log Folder parameter, if file logging is disabled but a parent logger with a file handler is assigned.

Path To Log File Pathtologfile - When a parameter of the current Logger COMP gets changed, it can have an impact on the current log file path.

When the current logger doesn't have file logging turned on, it doesn't mean that the log messages are not passed to a file. The messages could be passed to a parent logger which itself will have a file handler. Internally the Logger COMP attempts to find the path to a parent logger file handler and the path would be filled automatically here.

Add PID to file name Addpidtofilename - This will add the current process PID to the file name. This can be useful to split log files originating from the same project but ran in multiple processes.

Open Log File Openlogfile - Open the current log file. Similarly to the Open Log Folder parameter, the log to file parameter doesn't have to be turned on to open the log file. A log file might be currently used by the Logger COMP if a handler is present on a parent logger.

File Rotation Filerotation - Number of backup files to be kept when rotating log.

When When - When (or the interval types): 'S' (Seconds), 'M' (Minutes), 'H' (Hours), and 'D' (Days) specify how often log files should be rolled over, they don't influence the calculation of the initial rollover time. 'W0'-'W6' (Weekday, Monday to Sunday) and 'midnight' can use the 'At Time' parameter to compute the initial rollover time.

Interval Interval - The interval, where the unit is the "When" parameter. I.e., if the 'When' parameter is set to be 'H', and the Interval is 24, it will effectively rotate files every 24 hours. Setting the 'When' parameter to be 'D' and the Interval to be 1 will have the same behaviour.

At Time Attime - In format HH:MM:SS. Only used for weekdays (W0-W6) or 'midnight' as 'When' parameter.

Callback Callback -

Callback DAT Callbackdat - A DAT with a onMessageLogged(info) method.

Create Callback DAT Createcallbackdat - Create a valid callback DAT from the template shipping with the COMP.

Print Callbacks Printcallbacks - Print the callback details to the textport.


Parameters - About Page

Help Help -

Version Version -

.tox Save Build Toxsavebuild -

TouchDesigner Build: