Changeset 2001
- Timestamp:
- 15/12/2007 20:03:50 (13 months ago)
- Location:
- box/trunk/lib/common
- Files:
-
- 2 modified
-
Logging.cpp (modified) (4 diffs)
-
Logging.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/common/Logging.cpp
r1789 r2001 21 21 #include <iomanip> 22 22 23 #include "BoxTime.h" 24 23 25 bool Logging::sLogToSyslog = false; 24 26 bool Logging::sLogToConsole = false; … … 179 181 180 182 bool Console::sShowTime = false; 181 bool Console::sShowTag = false; 183 bool Console::sShowTimeMicros = false; 184 bool Console::sShowTag = false; 182 185 std::string Console::sTag; 183 186 … … 193 196 } 194 197 198 void Console::SetShowTimeMicros(bool enabled) 199 { 200 sShowTimeMicros = enabled; 201 } 202 195 203 bool Console::Log(Log::Level level, const std::string& rFile, 196 204 int line, std::string& rMessage) … … 212 220 if (sShowTime) 213 221 { 214 struct tm time_now, *tm_ptr = &time_now; 215 time_t time_t_now = time(NULL); 216 217 if (time_t_now == ((time_t)-1)) 218 { 219 msg += strerror(errno); 220 msg += " "; 221 } 222 box_time_t time_now = GetCurrentBoxTime(); 223 time_t seconds = BoxTimeToSeconds(time_now); 224 int micros = BoxTimeToMicroSeconds(time_now) % MICRO_SEC_IN_SEC; 225 226 struct tm tm_now, *tm_ptr = &tm_now; 227 222 228 #ifdef WIN32 223 else if ((tm_ptr = localtime(&time_t_now)) != NULL)229 if ((tm_ptr = localtime(&seconds)) != NULL) 224 230 #else 225 else if (localtime_r(&time_t_now, &time_now) != NULL)231 if (localtime_r(&seconds, &tm_now) != NULL) 226 232 #endif 227 233 { 228 234 std::ostringstream buf; 235 229 236 buf << std::setfill('0') << 230 237 std::setw(2) << tm_ptr->tm_hour << ":" << 231 238 std::setw(2) << tm_ptr->tm_min << ":" << 232 std::setw(2) << tm_ptr->tm_sec << " "; 239 std::setw(2) << tm_ptr->tm_sec; 240 241 if (sShowTimeMicros) 242 { 243 buf << "." << std::setw(6) << micros; 244 } 245 246 buf << " "; 233 247 msg += buf.str(); 234 248 } -
box/trunk/lib/common/Logging.h
r1938 r2001 119 119 private: 120 120 static bool sShowTime; 121 static bool sShowTimeMicros; 121 122 static bool sShowTag; 122 123 static std::string sTag; … … 130 131 static void SetTag(const std::string& rTag); 131 132 static void SetShowTime(bool enabled); 133 static void SetShowTimeMicros(bool enabled); 132 134 }; 133 135
