OpenWGA 7.5 - TMLScript reference


Object:

Console

Description

The console object can be used to log messages to the application log.

The console API is a de-facto standard API of JavaScript, found in many JavaScript frameworks to log messages to some debugging output. In TMLScript this is an alternative to using the log object on TMLContext, whose output also goes to the application log, which might be a bit more familiar to JavaScript developers.

All message logging methods of this object have in common that they take a message as argument plus a custom number of additional parameters which are to be inserted somewhere into the message. To indicate the position for those parameters the following substitution patterns can be used inside the message:

  • %s - A string parameter
  • %d or %i - An integer number parameter
  • %f - A floating point number parameter

If more parameters than string substitution patterns are given all of the left parameters are added at the end of the message.

Retrieval As predefined object "console" on every TMLScript expression
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Properties and methods
Name Purpose
debug(msg [, param, param, ...]) Logs a message of log level "debug"
error(msg [, param, param, ...]) Logs a message of log level "error"
info(msg [, param, param, ...]) Logs a message of log level "info"
log(msg [, param, param, ...]) Logs a message of log level "info"
time(timerName) Creates and starts a timer to take the time of a TMLScript operation
timeEnd(timerName) Stops a timer created by time() and logs the elapsed time
warn(msg [, param, param, ...]) Logs a message of log level "warn"
Examples

Writing a message to the application log, injecting the content key of the document in context as parameter:

console.log("Document %s was updated", KEY);