TR_Debugger – Construct 2 professional debug tool

-= [Buy in Scirra store] =-

DESCRIPTION

TR_Debugger is a tag based debug tool (plugin) which lets you comfortably debug your entire project or its sections. You can stream logs to three predefined outputs: Console, StackTrace and Custom. Custom output allows to stream log to any custom output like file, Text or Sprite Font object.

Each log has its tag (can have many tags) by which it is possible to filter the output. By default, tag parameter is set to General.

It is possible to enable/disable particular tags which will result in logging or not logging entries marked by provided tags – in other words toggle testing of particular app sections.

For example you can set some logs on your startup/initialization game process and tag them with initialization tag, your character related features tag with player tag and all the general actions with General tag. By default all logs are processed, however if you don’t want to see the initialization logs at the moment, you can simply disable them by disabling the initialization tag. If you have many different tags across your project and currently you want to see only logs related to your player (because you are working on your player right now for instance) then you can enable Tag Spotlight mode for player tag, you will see only logs related to your player code.

Filtering by tags lets you quickly check behaviour of each part of your project.

A word about Log action parameter called Output.

Logging to the Console output behaves similiarly to Browser.log action, which means it simply puts your data to the browser console. This is a common way to debug HTML5 apps during development. If you try to log to console in the environment which has no access to the browser (like CocoonIO Canvas+) then this action will be ignored.

Logging to the Stack trace output adds entry to the memory buffer – the Stack Trace. It does not log to the browser console, but stores the logs in the memory. The stack trace can be then retrieved with TR_Debugger.GetStackTrace(separator) expression as a string with all entries glued by separator parameter (by default it’s a newline character). It is useful if you want to keep the plugin active on production to generate stack trace report in case of some error. You can then send back such report back to you with AJAX.

Logging to the Custom output is useful for debugging apps which have no access to the browser, like CocoonIO Canvas+ apps. Every time custom log action is called, the On Custom log condition triggers and the log can be fetched with TR_Debugger.GetLastCustomLog expression. You can use it to output the log data to Text, SpriteFont, TextBox or any other object simply by setting Text.setText(TR_Debugger.GetLastCustomLog) (or equivalent) under On Custom log condition.

Each log has a timestamp prefix by default.

Timestamp prefix is automatically added to every log. You can set one of several predefined UNIX or Date timestamp formats or disable timestamp prefix at all. Timestamp by default returns the UTC time, but you can set the timestamp offset in hours (positive or negative) in the plugin properties. If you want all timestamp to return UTC + 2 time, simply set Timestamp offset property to 2, analogically setting it to -5 will return UTC -5 time etc.

NOTE that you don’t have to remove log actions from the event sheet when you export your project to production. Simply disable the plugin by setting plugin State property to Disabled. You can also set it to Production if you want to log the stack trace.

 


ACE’s infortmation exported with Armaldio’s C2 Addon Parser


PLUGIN PROPERTIES

State – The current state of the plugin.

  • Debug
    Every Log type enabled (Console, Memory and Report).
  • Production
    Console and Memory Log actions will have no effect. Only Logging to Report is enabled in this state.
  • Disabled
    Plugin disabled. None of Log actions will work.

Timestamp mode
The log prefix timestamp format.

Timestamp offset
Timestamp prefix offset in hours (0 is UTC time)

Stack trace limit
The maximum number of logs the stack trace can store. Set to 0 for no limit.

Assert report type – type of entry in case of assertion failure.

  • Simple
    One line entry with basic details.
  • Detailed
    Multi-line entry with all details.

Actions

There are 8 actions available

Log : Log a data to selected Output. #Log

  • Output : Choose the log output destination.
    • All
    • Console
    • Stack trace
    • Custom
  • Data : Enter the data (text or number) you want to log.
  • Tag : Add a tag to the log. Multi tagging is available by separating them with comma ex. “Feature1,Feature2,Feature3” (default value : “General”)

Clear stack trace : Clears the stack trace buffer. #Stack Trace


Set tag state : Logs with at least one assigned tag disabled will be silent. #Tag

  • Tag : Enter tag name. You can enter more than one tag by separating them with comma ex. “Feature1,Feature2,Feature3”
  • Set tag state : Logs with all assigned tags disabled will be silent.
    • Disabled
    • Enabled

Start tag spotlight : Start spotlight mode for tag (or comma separated tags ex. “Feature1,Feature2,Feature3”). #Tag

  • Tag : Enter tag name. You can enter more than one tag by separating them with comma ex. “Feature1,Feature2,Feature3”

End tag spotlight : Stop tag spotlight mode and start regular tag filter rules. #Tag


Start global spotlight : Start global spotlight mode no matter of the tags state or current tag spotlight. #Global


End global spotlight : Stop global spotlight mode and start regular tag filter rules or tag spotlight if activated. #Global


Assert : Test if given assertion is true. Otherwise log assertion warning. #Assertion

  • Assertion : Assertion to test. If assertion is not true, assertion warning will be broadcasted to all outputs.
  • Warning message : Custom warning message for this assertion.

Conditions

There are 6 conditions available

On Console log : Triggered when logged to console. #General


On Stack trace log : Triggered when logged to stack trace. #Stack Trace


On Custom log : Triggered when logged to custom output. #Custom


On Any log : Triggered when logged to any output. #General


Is in state : True when plugin is in selected state. #General

  • State : Choose the state.
    • Debug
    • Production
    • Disabled

On assertion failed: Triggered when assertion fails. #Assertion


Expressions

There are 9 expressions available

GetLastLog : Return the last log (no matter the output). #General


GetLastConsoleLog : Return the last log with Console output. #General


GetStackTrace : Return the Stack Trace as string separated with provided separator. #Stack Trace

  • newline : String to glue the logs together.

GetStackTraceSize : Return the number of logs added to the Stack Trace. #Stack Trace


GetLastStackTraceLog : Return the last Stack Trace entry. #Stack Trace


GetLastCustomLog : Return the last log with Custom output. #Custom


GetProjectInfo : Return the project info as string separated with provided separator. #General

  • newline : String to glue the rows together.

GetCurrentState : Return the current state of FPS, memory and CPUutilisation. #General


GetDataType : Return the data type. #General

  • data : Data to check type of.