diff -r a0946f209866 src/core/log.cc --- a/src/core/log.cc Mon Oct 20 13:31:25 2008 +0200 +++ b/src/core/log.cc Mon Oct 20 14:03:30 2008 +0200 @@ -177,6 +177,10 @@ else if (lev == "prefix_time") { level |= LOG_PREFIX_TIME; + } + else if (lev == "prefix_time_s") + { + level |= LOG_PREFIX_TIME_S; } else if (lev == "level_error") { diff -r a0946f209866 src/core/log.h --- a/src/core/log.h Mon Oct 20 13:31:25 2008 +0200 +++ b/src/core/log.h Mon Oct 20 14:03:30 2008 +0200 @@ -51,7 +51,8 @@ LOG_LEVEL_ALL = LOG_ALL, LOG_PREFIX_FUNC = 0x80000000, // prefix all trace prints with function - LOG_PREFIX_TIME = 0x40000000 // prefix all trace prints with simulation time + LOG_PREFIX_TIME = 0x40000000, // prefix all trace prints with simulation time + LOG_PREFIX_TIME_S = 0x20000000 // prefix all trace prints with simulation time (seconds) }; /** @@ -149,12 +150,20 @@ static ns3::LogComponent g_log = ns3::LogComponent (name) #define NS_LOG_APPEND_TIME_PREFIX \ - if (g_log.IsEnabled (ns3::LOG_PREFIX_TIME)) \ + if (g_log.IsEnabled (ns3::LOG_PREFIX_TIME) || \ + g_log.IsEnabled (ns3::LOG_PREFIX_TIME_S)) \ { \ ns3::LogTimePrinter printer = ns3::LogGetTimePrinter (); \ if (printer != 0) \ { \ - (*printer) (std::clog); \ + if (g_log.IsEnabled (ns3::LOG_PREFIX_TIME_S)) \ + { \ + (*printer) (std::clog, true); \ + } \ + else if (g_log.IsEnabled (ns3::LOG_PREFIX_TIME)) \ + { \ + (*printer) (std::clog, false); \ + } \ std::clog << " "; \ } \ } @@ -319,7 +328,7 @@ */ void LogComponentPrintList (void); -typedef void (*LogTimePrinter) (std::ostream &os); +typedef void (*LogTimePrinter) (std::ostream &os, bool printSeconds); void LogSetTimePrinter (LogTimePrinter); LogTimePrinter LogGetTimePrinter(void); diff -r a0946f209866 src/simulator/simulator.cc --- a/src/simulator/simulator.cc Mon Oct 20 13:31:25 2008 +0200 +++ b/src/simulator/simulator.cc Mon Oct 20 14:03:30 2008 +0200 @@ -57,9 +57,16 @@ // static void -TimePrinter (std::ostream &os) +TimePrinter (std::ostream &os, bool printSeconds) { - os << Simulator::Now (); + if (printSeconds) + { + os << Simulator::Now ().GetSeconds () << "s"; + } + else + { + os << Simulator::Now (); + } } #endif /* NS3_LOG_ENABLE */