| 1 | // boostLogger.cpp : Defines the entry point for the console application.
|
|---|
| 2 | //
|
|---|
| 3 |
|
|---|
| 4 | #include "stdafx.h"
|
|---|
| 5 |
|
|---|
| 6 | #include <fstream>
|
|---|
| 7 | #include <iomanip>
|
|---|
| 8 | #include <boost/log/core.hpp>
|
|---|
| 9 | #include <boost/log/expressions.hpp> // logging::trivial::severity
|
|---|
| 10 | #include <boost/log/sinks/sync_frontend.hpp>
|
|---|
| 11 | #include <boost/log/sinks/text_ostream_backend.hpp>
|
|---|
| 12 |
|
|---|
| 13 | #include <boost/smart_ptr/shared_ptr.hpp>
|
|---|
| 14 |
|
|---|
| 15 | namespace sinks = boost::log::sinks;
|
|---|
| 16 | namespace expr = boost::log::expressions;
|
|---|
| 17 |
|
|---|
| 18 | int _tmain(int argc, _TCHAR* argv[])
|
|---|
| 19 | {
|
|---|
| 20 | // Make a sink with a synchronous frontend and a streaming text backend
|
|---|
| 21 | typedef sinks::synchronous_sink< sinks::text_ostream_backend > text_sink;
|
|---|
| 22 | boost::shared_ptr< text_sink > sink = boost::make_shared< text_sink >( );
|
|---|
| 23 |
|
|---|
| 24 | // Add a stream to write log to
|
|---|
| 25 | sink->locked_backend( )->add_stream( boost::make_shared< std::ofstream >( "sample.log" ) );
|
|---|
| 26 |
|
|---|
| 27 | const int myWidth = 5;
|
|---|
| 28 |
|
|---|
| 29 | sink->set_formatter( expr::stream
|
|---|
| 30 | << std::setw( myWidth ) << "[ " << expr::attr< char >( "side" ) << " ] "
|
|---|
| 31 | << std::setw( myWidth ) << "[ " << expr::attr< char >( "uplo" ) << " ] "
|
|---|
| 32 | << std::setw( myWidth ) << "[ " << expr::attr< char >( "transa" ) << " ] "
|
|---|
| 33 | << std::setw( myWidth ) << "[ " << expr::attr< char >( "transb" ) << " ] "
|
|---|
| 34 | << std::setw( myWidth ) << "[ " << expr::attr< char >( "diag" ) << " ] "
|
|---|
| 35 | << std::setw( myWidth ) << "[ " << expr::attr< int >( "M" ) << " ] "
|
|---|
| 36 | << std::setw( myWidth ) << "[ " << expr::attr< int >( "N" ) << " ] "
|
|---|
| 37 | << std::setw( myWidth ) << "[ " << expr::attr< int >( "K" ) << " ] "
|
|---|
| 38 | << std::setw( myWidth ) << "[ " << expr::attr< float >( "alpha" ) << " ] "
|
|---|
| 39 | << std::setw( myWidth ) << "[ " << expr::attr< float* >( "A" ) << " ] "
|
|---|
| 40 | << std::setw( myWidth ) << "[ " << expr::attr< int >( "lda" ) << " ] "
|
|---|
| 41 | << std::setw( myWidth ) << "[ " << expr::attr< float* >( "B" ) << " ] "
|
|---|
| 42 | << std::setw( myWidth ) << "[ " << expr::attr< int >( "ldb" ) << " ] "
|
|---|
| 43 | << std::setw( myWidth ) << "[ " << expr::attr< float >( "beta" ) << " ] "
|
|---|
| 44 | << std::setw( myWidth ) << "[ " << expr::attr< float* >( "C" ) << " ] "
|
|---|
| 45 | << std::setw( myWidth ) << "[ " << expr::attr< int >( "ldc" ) << " ] "
|
|---|
| 46 | << std::setw( myWidth ) << "[ " << expr::attr< int >( "extra1" ) << " ] "
|
|---|
| 47 | << std::setw( myWidth ) << "[ " << expr::attr< int >( "extra2" ) << " ] "
|
|---|
| 48 | << std::setw( myWidth ) << "[ " << expr::attr< int >( "extra3" ) << " ] "
|
|---|
| 49 | << expr::smessage );
|
|---|
| 50 |
|
|---|
| 51 | return 0;
|
|---|
| 52 | }
|
|---|