diff --git a/examples/app/vsgviewer/vsgviewer.cpp b/examples/app/vsgviewer/vsgviewer.cpp index d8bef17b..5190715d 100644 --- a/examples/app/vsgviewer/vsgviewer.cpp +++ b/examples/app/vsgviewer/vsgviewer.cpp @@ -50,6 +50,9 @@ int main(int argc, char** argv) // set up defaults and read command line arguments to override them vsg::CommandLine arguments(&argc, argv); + // if we want to redirect std::cout and std::cerr to the vsg::Logger call vsg::Logger::redirect_stdout() + if (arguments.read({"--redirect-std", "-r"})) vsg::Logger::instance()->redirect_std(); + // set up vsg::Options to pass in filepaths, ReaderWriters and other IO related options to use when reading and writing files. auto options = vsg::Options::create(); options->sharedObjects = vsg::SharedObjects::create(); diff --git a/examples/io/vsglog/vsglog.cpp b/examples/io/vsglog/vsglog.cpp index 9b61b9f1..2ae63e9c 100644 --- a/examples/io/vsglog/vsglog.cpp +++ b/examples/io/vsglog/vsglog.cpp @@ -10,27 +10,27 @@ class CustomLogger : public vsg::Inherit protected: void debug_implementation(const std::string_view& message) override { - std::cout<<"custom debug : "<(message.length()), message.data()); } void info_implementation(const std::string_view& message) override { - std::cout<<"custom info : "<(message.length()), message.data()); } void warn_implementation(const std::string_view& message) override { - std::cerr<<"custom warn : "<(message.length()), message.data()); } void error_implementation(const std::string_view& message) override { - std::cerr<<"custom error : "<(message.length()), message.data()); } void fatal_implementation(const std::string_view& message) override { - std::cerr<<"custom error : "<(message.length()), message.data()); throw vsg::Exception{std::string(message)}; } }; @@ -46,7 +46,12 @@ int main(int argc, char** argv) // you can override the message verbosity by setting the minimum level that will be printed. vsg::Logger::instance()->level = level; + // if we want to redirect std::cout and std::cerr to the vsg::Logger call vsg::Logger::redirect_stdout() + if (arguments.read({"--redirect-std", "-r"})) vsg::Logger::instance()->redirect_std(); + // simplest form of messaging gets passed to the vsg::Logger::instance(). + std::cout<<"cout cstring"< auto level = vsg::Logger::Level(1 + value % 4); vsg::info("info() operation ",value); vsg::log(level, "log() operation ",value); + std::cout<<"cout operation "<setThreadPrefix(std::this_thread::get_id(), "main | "); vsg::CommandLine arguments(&argc, argv); + + // if we want to redirect std::cout and std::cerr to the vsg::Logger call vsg::Logger::redirect_stdout() + if (arguments.read({"--redirect-std", "-r"})) vsg::Logger::instance()->redirect_std(); + auto numThreads = arguments.value(16, "-t"); auto count = arguments.value(100, "-n"); auto level = vsg::Logger::Level(arguments.value(0, "-l"));