DiagnosticsModule Module

The DiagnosticsModule class enables diagnostic logging.

Usage

const Diagnostics = require('Diagnostics');

Properties

This class exposes no properties.

Methods

MethodDescription

log(content: Object)

returns void

Flattens content to a string and prints it to the debug console.

watch(tag: String, signal:BoolSignal)

returns void

watch(tag: String, signal:ScalarSignal)

returns void

watch(tag: String, signal:StringSignal)

returns void

Adds the specified signal to the watch view in AR Studio with the specified tag.

Example

The following example demonstrates how to set a single-event timer, and a timer that is activated every 1.7 seconds, both of which log to the debug console.

const Time = require('Time');
const Diagnostics = require('Diagnostics');

// One-shot timers:
Time.setTimeout(
  function (elapsedTime) { 
    Diagnostics.log('You should see this message in the console.'); 
  }, 1300);

var cancelableTimer = Time.setTimeout(
  function (elapsedTime) { 
    Diagnostics.log('You should not see this message in the console.'); 
  }, 2900);

// Repeating timer:
Time.ms.interval(1700).subscribe(
  function (elapsedTime) {
    // NOTE: Time.ms may differ slightly from the elapsed
    // time passed to the callback. Time.ms shows the exact
    // time since the effect started, whereas the callback
    // exposes an exact multiple of the specified interval.
    Diagnostics.log(Time.ms.lastValue);
    Diagnostics.log(elapsedTime);
    Time.clearTimeout(cancelableTimer);
  });