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.
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
Parameters - Settings Page
Active - When the active flag is turned off, most logging messages will be silenced and log levels are ignored.
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.
Propagate to parent(s)
Propagate - When using parenting, use this toggle if you wish to prevent messages from being passed to the parent.
Origin - Reference a COMP for the logger to mention where the log messages are originating from.
Push logger page to origin
Pushto - "Push to" create a Logger page if not available at the origin level. It also binds parameters.
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.
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
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.
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.
Filerotation - Number of backup files to be kept when rotating log.
Callbackdat - A DAT with a onMessageLogged(info) method.
Create Callback DAT
Createcallbackdat - Create a valid callback DAT from the template shipping with the COMP.
Printcallbacks - Print the callback details to the textport.
Parameters - About Page
.tox Save Build