View | Details | Raw Unified | Return to bug 257
Collapse All | Expand All

(-)a/src/core/log.cc (+4 lines)
 Lines 177-182    Link Here 
177
                  else if (lev == "prefix_time")
177
                  else if (lev == "prefix_time")
178
                    {
178
                    {
179
                      level |= LOG_PREFIX_TIME;
179
                      level |= LOG_PREFIX_TIME;
180
                    }
181
                  else if (lev == "prefix_time_s")
182
                    {
183
                      level |= LOG_PREFIX_TIME_S;
180
                    }
184
                    }
181
                  else if (lev == "level_error")
185
                  else if (lev == "level_error")
182
                    {
186
                    {
(-)a/src/core/log.h (-4 / +13 lines)
 Lines 51-57    Link Here 
51
  LOG_LEVEL_ALL      = LOG_ALL,
51
  LOG_LEVEL_ALL      = LOG_ALL,
52
52
53
  LOG_PREFIX_FUNC    = 0x80000000, // prefix all trace prints with function
53
  LOG_PREFIX_FUNC    = 0x80000000, // prefix all trace prints with function
54
  LOG_PREFIX_TIME    = 0x40000000  // prefix all trace prints with simulation time
54
  LOG_PREFIX_TIME    = 0x40000000, // prefix all trace prints with simulation time
55
  LOG_PREFIX_TIME_S  = 0x20000000  // prefix all trace prints with simulation time (seconds)
55
};
56
};
56
57
57
/**
58
/**
 Lines 149-160    Link Here 
149
  static ns3::LogComponent g_log = ns3::LogComponent (name)
150
  static ns3::LogComponent g_log = ns3::LogComponent (name)
150
151
151
#define NS_LOG_APPEND_TIME_PREFIX                               \
152
#define NS_LOG_APPEND_TIME_PREFIX                               \
152
  if (g_log.IsEnabled (ns3::LOG_PREFIX_TIME))                   \
153
  if (g_log.IsEnabled (ns3::LOG_PREFIX_TIME) ||                 \
154
      g_log.IsEnabled (ns3::LOG_PREFIX_TIME_S))                 \
153
    {                                                           \
155
    {                                                           \
154
      ns3::LogTimePrinter printer = ns3::LogGetTimePrinter ();  \
156
      ns3::LogTimePrinter printer = ns3::LogGetTimePrinter ();  \
155
      if (printer != 0)                                         \
157
      if (printer != 0)                                         \
156
        {                                                       \
158
        {                                                       \
157
          (*printer) (std::clog);                               \
159
          if (g_log.IsEnabled (ns3::LOG_PREFIX_TIME_S))         \
160
            {                                                   \
161
              (*printer) (std::clog, true);                     \
162
            }                                                   \
163
          else if (g_log.IsEnabled (ns3::LOG_PREFIX_TIME))      \
164
            {                                                   \
165
              (*printer) (std::clog, false);                    \
166
            }                                                   \
158
          std::clog << " ";                                     \
167
          std::clog << " ";                                     \
159
        }                                                       \
168
        }                                                       \
160
    }
169
    }
 Lines 319-325    Link Here 
319
 */
328
 */
320
void LogComponentPrintList (void);
329
void LogComponentPrintList (void);
321
330
322
typedef void (*LogTimePrinter) (std::ostream &os);
331
typedef void (*LogTimePrinter) (std::ostream &os, bool printSeconds);
323
332
324
void LogSetTimePrinter (LogTimePrinter);
333
void LogSetTimePrinter (LogTimePrinter);
325
LogTimePrinter LogGetTimePrinter(void);
334
LogTimePrinter LogGetTimePrinter(void);
(-)a/src/simulator/simulator.cc (-2 / +9 lines)
 Lines 57-65    Link Here 
57
// 
57
// 
58
58
59
static void
59
static void
60
TimePrinter (std::ostream &os)
60
TimePrinter (std::ostream &os, bool printSeconds)
61
{
61
{
62
  os << Simulator::Now ();
62
  if (printSeconds)
63
    {
64
      os << Simulator::Now ().GetSeconds () << "s";
65
    }
66
  else
67
    {
68
      os << Simulator::Now ();
69
    }
63
}
70
}
64
71
65
#endif /* NS3_LOG_ENABLE */
72
#endif /* NS3_LOG_ENABLE */

Return to bug 257