Login | Register 

simple error logging

Share your components here. First one to 100 wins!

simple error logging

Postby raganmd » Wed Apr 05, 2017 4:52 pm

Every once and awhile I can share something that is't locked into a given project. We've been kicking around how to properly log our touch projects for a bit and have tried several different approaches. I think this is getting close to a consistent and re-usable tool for us, and I wanted to share in case you aren't interested in writing your own logger from scratch.

This logger supports sending log messages from anywhere in your network and the use of the error DAT to auto log any errors that might pop up for an installation. There's also a handy way of getting a performance snapshot out of your network - which is similar to the performance monitor (only all in a table). Anyhoo, hope it's useful to other folks as well.

Built with Touch099, though there's nothing that's 099 specific here. Check the readme and doc strings to see how it's working under the hood.


The logger tox is intended to help support textport and file logging for TouchDesigner projects.

Features and Parameters

Code: Select all
Log(   location='textport'| 'file' | 't&f',
      msg = '',
      loglvl = 0-3,
      verbose = bool,
      include_stats = bool,
      easy_locate = bool,
      target_op = touch operator,
      snapshot = bool,
      frame = 0,
      absFrame = 0 ):

The Log() method is the primary use tool of the logger. Largely this method will handled the rest of event logging based on the parmaters passed into it.
* You can log your message to the textport, to file, or to both with the string messages 'textport', 'file', or 't&f'.
* The message argument will be included in your log event.
* The verbose argument specifies if you want a single line log, or a multiline and more comprehensive log entry.
* Include stats similarly will include performance stats along with the logged message.
* Easy to locate will include a callout frame for your message in the log file, making it easier to locate an event in a large file.
* Target op should be a touch operator passed into the method.
* Snapshot, if true will take snapshot of current performance stats that will be included in the snapshots directory
* frame and absframe are largely used by the error DAT, though you are welcome to pass in frame times for them if you so choose. This data is only included in the verbose message

Code: Select all

Take a sanpshot will add a tab seperated value text file to a directory called "snapshots" that will be added to the log directory. Snapshots provide a more comprehensive look at what's happening in a network and can be useful for deeper debugging or investigating large cooktimes or other poor performance.

Code: Select all
Add_blacklist_op(   operator,
                    templist = bool

Blacklisting an operator will remove it from being logged by the Error DAT. This is especially helpful if you have an operator that produces a known error that you don't want to capture. Also worth knowing is that the Error DAT will add items to a tempblacklist if the error happens more than 10 times consecutivly - to prevent your log file from being filled by the same error. This clears when the extension is reinited, or when touch is restarted.


Project Name
The project name prepends any log files in case you're using a shared logging directory. This should allow for easy project recognition.

Log in Project
The log in project toggle is used to indicate if your log location is inside / outside of the project directory.

Log Location
The log directory path that you use in this parameteter is appended to the project directory if the above paramter is marked as On. For example, if your desired log location is in ```c:\projects\some.od.project\data\logs```, you should write ```data\logs``` in the Log Location parameter field. The directory path for the project will be retrieved with ```project.folder``` and does not need to be included when specifying log location.

If the Log in Project paramter is Off, you should supply a complete path to your desired log location.

Track Network Errors
This toggle will toggle the error DAT on or off - this allows for quiet logging during development, and more comprehensive logging when deployed. Alternativly this could be scripted to toggle when in perform mode.

Reset Snap Count
Snapshots are appended with a count in order to safeguard against snapshots requested within onesecond of one another . This also creates a nice record of how many snapshots have been taken in a given network over time. The int for this indexing is located in storage, and pulsing this parameter will reset the count to 0.
(6.35 KiB) Downloaded 53 times
Posts: 838
Joined: Thu Mar 28, 2013 5:21 am
Location: San Francisco, CA

Re: simple error logging

Postby asterix » Thu May 25, 2017 9:28 am

Very cool Matthew!
Posts: 114
Joined: Fri Jul 19, 2013 1:34 pm

Re: simple error logging

Postby raganmd » Thu May 25, 2017 12:26 pm

Glad I could share it - making straightforward reusable things is hard. :)
Posts: 838
Joined: Thu Mar 28, 2013 5:21 am
Location: San Francisco, CA

Return to Shared .tox Components

Who is online

Users browsing this forum: No registered users and 6 guests