2323
2424#include < cstdio>
2525#include < string>
26+ #include < fstream>
27+ #include < streambuf>
2628#include < unistd.h>
2729
2830SC_MODULE (test4) {
@@ -142,6 +144,14 @@ int sc_main(int argc, char** argv) {
142144
143145 std::string logfile = " /tmp/scp_smoke_report_test." +
144146 std::to_string (getpid ());
147+ scp::init_logging (
148+ scp::LogConfig ()
149+ .logLevel (scp::log::DEBUG) // set log level to debug
150+ .msgTypeFieldWidth (20 )
151+ .fileInfoFrom (5 )
152+ .logAsync (false )
153+ .printSimTime (false )
154+ .logFileName (logfile)); // make the msg type column a bit tighter
145155 SCP_INFO () << " Constructing design" ;
146156 test toptest (" top" );
147157 test1 t1 (" t1" );
@@ -150,5 +160,56 @@ int sc_main(int argc, char** argv) {
150160 sc_core::sc_start ();
151161 SCP_WARN () << " Ending simulation" ;
152162
153- return 0 ;
163+ #ifdef FMT_SHARED
164+ std::string fmtstr = " FMT String : Cached version default" ;
165+ #else
166+ std::string fmtstr = " Please add FMT library for FMT support." ;
167+ #endif
168+
169+ std::string expected =
170+ R"( [ info] [ 0 s ]SystemC : Constructing design
171+ [ info] [ 0 s ]out.class : constructor
172+ [ warning] [ 0 s ]out.class : constructor
173+ [ debug] [ 0 s ]top : First part
174+ [ info] [ 0 s ]top : top
175+ [ info] [ 0 s ]top : top->top->top
176+ [ debug] [ 0 s ]top : Second part
177+ [ info] [ 0 s ]ext test : Success
178+ [ info] [ 0 s ]SystemC : Uncached version empty
179+ [ info] [ 0 s ]top : )" +
180+ fmtstr + R"(
181+ [ info] [ 0 s ]top : UnCached version feature using SCMOD macro
182+ [ info] [ 0 s ]top : Cached version using (m_my_logger)
183+ [ info] [ 0 s ]top : Cached version with D
184+ [ info] [ 0 s ]t1.t2.t3_1 : . T3 D Logger "other" "feature.one"
185+ [ warning] [ 0 s ]t1.t2.t3_1 : . T3 D Logger "other" "feature.one"
186+ [ info] [ 0 s ]t1.t2.t3_1 : . T3 Logger ()
187+ [ warning] [ 0 s ]t1.t2.t3_1 : . T3 Logger ()
188+ [ info] [ 0 s ]t1.t2.t3_2 : . T3 D Logger "other" "feature.one"
189+ [ warning] [ 0 s ]t1.t2.t3_2 : . T3 D Logger "other" "feature.one"
190+ [ warning] [ 0 s ]t1.t2.t3_2 : . T3 Logger ()
191+ [ info] [ 0 s ]t1.t2.t4 : . T4 Logger() 1
192+ [ warning] [ 0 s ]t1.t2.t4 : . T4 Logger() 1
193+ [ info] [ 0 s ]t1.t2.t4 : . T4 Logger() 2
194+ [ warning] [ 0 s ]t1.t2.t4 : . T4 Logger() 2
195+ [ warning] [ 0 s ]t1.t2 : T2 Logger()
196+ [ warning] [ 0 s ]My.Name : T1 My.Name typed log
197+ [ warning] [ 0 s ]t1 : T1 Logger()
198+ [ info] [ 0 s ]t1 : Thing1?
199+ [ warning] [ 0 s ]t1 : Thing1?
200+ [ warning] [ 0 s ]t1 : Thing2?
201+ [ info] [ 0 s ]SystemC : Starting simulation
202+ [ warning] [ 0 s ]SystemC : Ending simulation
203+ )" ;
204+
205+ std::ifstream lf (logfile);
206+ std::string out ((std::istreambuf_iterator<char >(lf)),
207+ std::istreambuf_iterator<char >());
208+
209+ std::cout << " out file\n " << out << " \n " ;
210+ std::cout << " expected\n " << expected << " \n " ;
211+ std::cout << " Number of difference: " << out.compare (expected) << " \n " ;
212+
213+ std::remove (logfile.c_str ());
214+ return out.compare (expected);
154215}
0 commit comments