Changeset 2296 for box/trunk/lib/common/Logging.cpp
- Timestamp:
- 26/09/2008 21:22:26 (4 years ago)
- File:
-
- 1 edited
-
box/trunk/lib/common/Logging.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/common/Logging.cpp
r2279 r2296 223 223 } 224 224 225 Logger::Logger(Log::Level Level) 226 : mCurrentLevel(Level) 227 { 228 Logging::Add(this); 229 } 230 225 231 Logger::~Logger() 226 232 { … … 401 407 ::openlog(mName.c_str(), LOG_PID, LOG_LOCAL6); 402 408 } 409 410 bool FileLogger::Log(Log::Level Level, const std::string& rFile, 411 int line, std::string& rMessage) 412 { 413 if (Level > GetLevel()) 414 { 415 return true; 416 } 417 418 /* avoid infinite loop if this throws an exception */ 419 Logging::Remove(this); 420 421 std::ostringstream buf; 422 buf << FormatTime(GetCurrentBoxTime(), false); 423 buf << " "; 424 425 if (Level <= Log::FATAL) 426 { 427 buf << "[FATAL] "; 428 } 429 else if (Level <= Log::ERROR) 430 { 431 buf << "[ERROR] "; 432 } 433 else if (Level <= Log::WARNING) 434 { 435 buf << "[WARNING] "; 436 } 437 else if (Level <= Log::NOTICE) 438 { 439 buf << "[NOTICE] "; 440 } 441 else if (Level <= Log::INFO) 442 { 443 buf << "[INFO] "; 444 } 445 else if (Level <= Log::TRACE) 446 { 447 buf << "[TRACE] "; 448 } 449 450 buf << rMessage << "\n"; 451 std::string output = buf.str(); 452 453 #ifdef WIN32 454 ConvertUtf8ToConsole(output.c_str(), output); 455 #endif 456 457 mLogFile.Write(output.c_str(), output.length()); 458 459 Logging::Add(this); 460 return true; 461 }
Note: See TracChangeset
for help on using the changeset viewer.
