Skip to content

Log verbosity can't be controlled: start-up lines print before setLogLevel is reachable, and webarkit-info ignores it #677

Description

@kalwalt

Problem

An app cannot quieten jsartoolkitNFT's console output. setLogLevel() only reaches part of
it, and only after start-up. Measured with 1.13.0, default build, in Chrome:

Output Emitted by Affected by setLogLevel()?
[info] Page[0] pre: …, [info] Tracked page 0 (max 1)., [info] Tracking lost on page 0. ARToolKit ARLOG (WASM) Yes. At ARLogLevel.Warn, 8 frames of a two-target photo print 0 lines instead of 18, with the same detections.
ℹ️[webarkit-info:]…, e.g. Continuous detection: on, Detection interval: 300 ms, add NFT marker-> …, Reading /markerNFT_0.fset3, init ARToolKitNFT constructor... WebARKitLib's own logger (WASM) No. Still printed at ARLogLevel.Warn, although getLogLevel() returns 2.
ARToolkitNFT 1.13.0 console.info in the ARToolkitNFT constructor No (plain JS)
[ARControllerNFT] ARToolkitNFT initialized, … Camera params loaded with ID 0, … Got ID from setup 0 console.log in ARControllerNFT._initialize() No (plain JS)
add nft marker ids: [0] console.log in ARToolkitNFT.addNFTMarkers() No (plain JS)
*** Camera Parameter ***, SIZE = 320, 240, the distortion and camera matrix dump, setCamera(): arParamLTCreated ARLOG / parameter display during _initialize() Cannot be tested: printed before an app can call setLogLevel()

The timing is the main blocker. initWithDimensions() / initWithImage() run _initialize()
and only then hand the controller back. setLogLevel() is an instance method that needs
this.artoolkitNFT, which does not exist before _initialize(). customInit() runs its
callback earlier, but also too early for that instance to exist. So every app starts with
about 20 console lines it cannot turn off.

Suggested fix

  1. A log level at initialisation. For example an optional options argument,
    initWithDimensions(w, h, cameraParam, internalLuma, { logLevel }), or a static
    ARControllerNFT.setDefaultLogLevel(level) that _initialize() applies as soon as the
    ARToolkitNFT instance exists, before loadCamera() / setup().
  2. One level for WebARKit's logger too. setLogLevel() (and the start-up option) should
    also set the level of WebARKitLib's webarkit-info logger. Alternatively, expose a separate
    setter for it.
  3. Route the JS logs through the level. The version line, the [ARControllerNFT] … lines
    and add nft marker ids should respect the level, e.g. through a small logger that checks
    it. The version could be logged once at RelInfo so it can still be kept.

Context

Aframe-nft now calls setLogLevel() as soon as it
gets the controller (default warn). That silences the per-frame tracking lines but leaves
everything in the other rows of the table.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions