Skip to content

Route diagnostics to stderr, with levels #165

Open

Description

@HugoFara

Almost all output goes to stdout with no levels: 299 cout against 28 cerr, mostly in Command.cpp, FireDomain.cpp and DataBroker.cpp.

This causes two problems:

  • A passing unit-test run prints 34 ERROR: vector of parameters … should be valued lines, and none of them is an error. A real error would look identical.
  • Simulation output (FireNode[…] lines) and diagnostics share one stream, so scripts cannot tell them apart.

Suggested fix: a small logging header with levels (error/warning/info/debug) and a runtime threshold, sending errors and warnings to stderr. Then reclassify the call sites, which can be done gradually.

Worth doing before ensembles (#172). Easier after #164 (std::source_location).


Drafted with Claude Opus 5, reviewed by a maintainer.

Activity

  1. added
    refactorCode restructuring without intended behavior changes
    on Aug 12, 2026
  2. filippi commented on Oct 21, 2026

    @filippi
    Contributor

    isnt'it passed trhous the static context ? only one outspreamrep per process i guess..i cannot understant the proposed fix.. maybe for later

  3. HugoFara commented on Oct 29, 2026

    @HugoFara
    CollaboratorAuthor

    DataBroker, FireDomain and the layers write to cout directly. And even through outStream, results and errors are mixed: Error: No arguments provided. goes to the same place as print[]'s FireNode[...] lines.

    The result is that even a green CI prints dozens of these on stdout:
    WARNING: could not load file for fuel properties .../fuels.ff
    Error: Data name 'noSuchParameter' not recognized.

    Users and scripts can't tell which are errors and which should be ignored.

    I tend to use logging frameworks a lot because they make things much cleaner. But we can have a smaller version if you prefer: send the lines that already start with ERROR/WARNING/Error: to stderr and leave the rest alone. Results stay on stdout. Would that be OK?

  4. added theissue type on Oct 29, 2026
  5. antonio-leblanc commented on Nov 3, 2026

    @antonio-leblanc
    Collaborator

    What I understood: today the code prints everything the same way, so a real error looks just like a normal result or a harmless warning. Hugo's idea is to tag each message so we can tell them apart, the same thing Python's logging does:

    Python logging ForeFire (example)
    log.error("...") FF_ERROR << "..."
    log.warning("...") FF_WARN << "..."
    log.info / log.debug FF_INFO / FF_DEBUG
    basicConfig(level=WARNING) setParameter[logLevel=warning]

    Results stay exactly where they are. Only errors and warnings would go to stderr, and in a terminal you'd see the same thing as today. No new dependency, just a small header, and the change can be done file by file.

    This assumes no script or Meso-NH run reads the errors from the output. If one does, we keep that working.

    I like the idea. If @filippi is ok, Hugo, I can open a first small PR (header + a few files) and you review, or the other way around.

  6. antonio-leblanc commented on Nov 10, 2026

    @antonio-leblanc
    Collaborator

    Discussed with Filippi. Instead of a new logging header sending to stderr, he prefers reusing Command::Session: replace direct cout with session.log(level, msg), writing to the session stream (default cout, so the WASM/listenHTTP capture keeps working), with levels as a bitmask (ERROR | WARN | INFO | DEBUG; quiet = ERROR only). This revives the unused debugMode/COMMAND_DEBUG, and the existing CommandOutputs switch maps to the DEBUG bit.

    So results and diagnostics stay on one stream, separated by the mask rather than stdout/stderr. Filippi asked to hold off for now; when we pick it up, a first PR could cover Command.cpp only. Other files (FireFront, FireDomain, DataBroker) would need to depend on Command, to decide later.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorCode restructuring without intended behavior changes

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions