mariusmuja/flann — Issue #26: AutotunedIndex should respect logger level with print_params
Author: d00gs
Created: 2012-01-18 19:14:35+00:00
State: open

Specifically, [both calls to print_params here](https://github.com/mariusmuja/flann/blob/master/src/cpp/flann/algorithms/autotuned_index.h#L107) always print, and as far as I know, there's absolutely no way to disable them. (You can't hackily assign std::cout to something else in C++ as far as I know.)

This is particularly annoying for my application that does a lot of autotuning. If there is an easy workaround, of course, that's fine too.

One dumb but easy solution:

// in util/logger.h
static int Logger::getLevel() {
return instance().logLevel;
}

// in algorithms/autotuned_index.h
Logger::info("----------------------------------------------------\n");
Logger::info("Autotuned parameters:\n");
if (Logger::getLevel() <= FLANN_LOG_INFO)
print_params(bestParams_);
Logger::info("----------------------------------------------------\n");

A better but more-effort solution: have `Logger` provide output streams for each log level, and add an optional stream argument to `print_params` defaulting to `std::cout`.