fix(device): print --print-channels and --version output to stdout

- DeviceRunner sets the console log severity to "nolog" for both
  options, but printed their output with LOGV(info), so both options
  printed nothing
- Add Device::PrintRegisteredChannels(std::ostream&) for the
  machine-readable channel list; the version goes to std::cout, like
  --help and --print-options
- Enable DeviceRunner.PrintChannels and DeviceRunner.Version
- Update the documentation pages that described the defect, and
  the source line links into the changed files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-04 20:31:28 +00:00
committed by Dennis Klein
parent b70595cebe
commit 9b6662f6a9
18 changed files with 42 additions and 41 deletions

View File

@@ -33,6 +33,7 @@
#include <functional>
#include <memory> // unique_ptr
#include <mutex>
#include <ostream>
#include <stdexcept>
#include <string>
#include <unordered_map>
@@ -360,6 +361,15 @@ class Device
return ok;
}
/// @brief Print the registered channels in a machine-readable format
/// @param os output stream, one line per channel: <name>:<min sub-channels>:<max sub-channels>
void PrintRegisteredChannels(std::ostream& os) const
{
for (const auto& c : fChannelRegistry) {
os << c.first << ":" << c.second.first << ":" << c.second.second << "\n";
}
}
void PrintRegisteredChannels()
{
if (fChannelRegistry.empty()) {

View File

@@ -15,6 +15,7 @@
#include <fairlogger/Logger.h>
#include <exception>
#include <iostream>
using namespace std;
using namespace fair::mq;
@@ -154,15 +155,16 @@ auto DeviceRunner::Run() -> int
// Handle --print-channels
fDevice->RegisterChannelEndpoints();
if (fConfig.Count("print-channels")) {
fDevice->PrintRegisteredChannels();
// print to stdout: the console log severity is "nolog" for this option
fDevice->PrintRegisteredChannels(cout);
fDevice->ChangeStateOrThrow(fair::mq::Transition::End);
return 0;
}
// Handle --version
if (fConfig.Count("version")) {
LOGV(info, verylow) << "FairMQ version: " << FAIRMQ_GIT_VERSION;
LOGV(info, verylow) << "User device version: " << fDevice->GetVersion();
cout << "FairMQ version: " << FAIRMQ_GIT_VERSION << '\n'
<< "User device version: " << fDevice->GetVersion() << endl;
fDevice->ChangeStateOrThrow(fair::mq::Transition::End);
return 0;
}