문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top