Frage

In the qooxdoo tutorial we see this code:

if (qx.core.Environment.get("qx.debug"))
{
  qx.log.appender.Native;
  qx.log.appender.Console;
}

But the two statements in braces appear to simply be accessing some attribute by traversing a namespace hierarchy - they arent calling a function.

How can those 2 statements actually turn on logging?

War es hilfreich?

Lösung

This two statements make the two classes as required for the dependency analysis which then register themselfs in their defer blocks [1]. This way, a variant dependent dependency is managed.

[1] https://github.com/qooxdoo/qooxdoo/blob/master/framework/source/class/qx/log/appender/Native.js#L75

Andere Tipps

To put Martin's answer in other words, the code snippet just makes sure the classes (Native and Console) get added to the application build, provided that debugging is on. In that case qooxdoo's automatic dependency analysis detects the two symbols and adds them to the build.

Once included in the build they register themselves and hence make logging possible.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top