From: Matthew W. <mat...@ki...> - 2013-02-27 22:15:31
|
I am writing a file reader that tries to read data from a VSL stream of unknown format. Since there is no eyecatcher or other identifying mark in the file, the only way I know of to do this is to attempt to read the data and watch for failures, and use that to guess what type of file I am dealing with. (Fortunately the possible data layouts are such that it is unlikely that trying to read one type of file as the wrong type will succeed.) This seems like a reasonable approach, but it is VERY noisy due to a bunch of output that VSL spews to stderr. Since I am doing speculative reads, I expect there is a good chance they will fail, and that this is not an error and should not spam the user's console output. I could use dup2 to monkey around with stderr, but this is not a good thing to be doing in a library and in a multi-threaded context. Would it be reasonable to patch vsl_b_istream and the various vsl_b_read such that the user can specify a different output stream to use for outputting such error messages? (I'm thinking to set a std::ostream* on the vsl_b_istream to use for error output; the default would be &vcl_cerr. The caller would be responsible for correctly managing the life cycle of the std::ostream object.) -- Matthew |