44
55#include < plog/Log.h>
66#include < plog/Initializers/RollingFileInitializer.h>
7+ #include < plog/Formatters/TxtFormatter.h>
8+ #include < plog/Appenders/ColorConsoleAppender.h>
9+
10+ #include < vector>
11+ #include < deque>
12+ #include < list>
13+ #include < map>
14+ #include < set>
715
816#include " MyClass.h"
917#include " Customer.h"
@@ -20,7 +28,10 @@ void unmanagedFunc()
2028
2129int main ()
2230{
23- plog::init (plog::debug, " Demo.csv" , 5000 , 3 ); // Initialize the logger.
31+ plog::init (plog::debug, " Demo.csv" , 5000 , 3 ); // Initialize logging to the file.
32+
33+ plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender;
34+ plog::get ()->addAppender (&consoleAppender); // Also add logging to the console.
2435
2536 // Log macro types.
2637 PLOGD << " Hello log!" ; // short macro
@@ -121,5 +132,50 @@ int main()
121132 Customer customer = { 10 , " John" };
122133 PLOG_INFO << customer;
123134
135+ // Std containers can be printed
136+ std::vector<int > vectorOfInts;
137+ vectorOfInts.push_back (1 );
138+ vectorOfInts.push_back (2 );
139+ vectorOfInts.push_back (3 );
140+ PLOG_INFO << " std::vector<int>: " << vectorOfInts;
141+
142+ std::deque<std::string> dequeOfStrings;
143+ dequeOfStrings.push_back (" one" );
144+ dequeOfStrings.push_back (" two" );
145+ dequeOfStrings.push_back (" three" );
146+ PLOG_INFO << " std::deque<std::string>: " << dequeOfStrings;
147+
148+ std::list<const char *> listOfCharPointers;
149+ listOfCharPointers.push_back (" one" );
150+ listOfCharPointers.push_back (" two" );
151+ listOfCharPointers.push_back (NULL );
152+ PLOG_INFO << " std::list<const char*>: " << listOfCharPointers;
153+
154+ std::set<int > setOfInts;
155+ setOfInts.insert (10 );
156+ setOfInts.insert (20 );
157+ setOfInts.insert (30 );
158+ PLOG_INFO << " std::set<int>: " << setOfInts;
159+
160+ std::map<std::string, int > mapStringToInt;
161+ mapStringToInt[" red" ] = 1 ;
162+ mapStringToInt[" green" ] = 2 ;
163+ mapStringToInt[" blue" ] = 4 ;
164+ PLOG_INFO << " std::map<std::string, int>: " << mapStringToInt;
165+
166+ std::multimap<int , std::string> multimapIntToString;
167+ multimapIntToString.insert (std::make_pair (1 , " one" ));
168+ multimapIntToString.insert (std::make_pair (1 , " uno" ));
169+ multimapIntToString.insert (std::make_pair (2 , " two" ));
170+ multimapIntToString.insert (std::make_pair (2 , " due" ));
171+ PLOG_INFO << " std::multimap<int, std::string>: " << multimapIntToString;
172+
173+ std::vector<std::vector<int > > vectorOfVectorsOfInts (3 );
174+ vectorOfVectorsOfInts[0 ].push_back (1 );
175+ vectorOfVectorsOfInts[0 ].push_back (2 );
176+ vectorOfVectorsOfInts[1 ].push_back (-1 );
177+ vectorOfVectorsOfInts[1 ].push_back (-2 );
178+ PLOG_INFO << " std::vector<std::vector<int> >: " << vectorOfVectorsOfInts;
179+
124180 return 0 ;
125181}
0 commit comments