Changeset 2466
- Timestamp:
- 24/03/2009 16:55:46 (3 years ago)
- Location:
- box/trunk/lib
- Files:
-
- 4 edited
-
common/Logging.cpp (modified) (3 diffs)
-
common/Logging.h (modified) (3 diffs)
-
server/Daemon.cpp (modified) (1 diff)
-
server/Daemon.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/common/Logging.cpp
r2465 r2466 217 217 } 218 218 219 void Logging::SetFacility(int facility) 220 { 221 spSyslog->SetFacility(facility); 222 } 223 219 224 Logger::Logger() 220 225 : mCurrentLevel(Log::EVERYTHING) … … 391 396 } 392 397 393 Syslog::Syslog() 394 { 395 ::openlog("Box Backup", LOG_PID, LOG_LOCAL6);398 Syslog::Syslog() : mFacility(LOG_LOCAL6) 399 { 400 ::openlog("Box Backup", LOG_PID, mFacility); 396 401 } 397 402 … … 405 410 mName = rProgramName; 406 411 ::closelog(); 407 ::openlog(mName.c_str(), LOG_PID, LOG_LOCAL6); 412 ::openlog(mName.c_str(), LOG_PID, mFacility); 413 } 414 415 void Syslog::SetFacility(int facility) 416 { 417 mFacility = facility; 418 ::closelog(); 419 ::openlog(mName.c_str(), LOG_PID, mFacility); 420 } 421 422 int Syslog::GetNamedFacility(const std::string& rFacility) 423 { 424 #define CASE_RETURN(x) if (rFacility == #x) { return LOG_ ## x; } 425 CASE_RETURN(LOCAL0) 426 CASE_RETURN(LOCAL1) 427 CASE_RETURN(LOCAL2) 428 CASE_RETURN(LOCAL3) 429 CASE_RETURN(LOCAL4) 430 CASE_RETURN(LOCAL5) 431 CASE_RETURN(LOCAL6) 432 CASE_RETURN(DAEMON) 433 #undef CASE_RETURN 434 435 BOX_ERROR("Unknown log facility '" << rFacility << "', " 436 "using default LOCAL6"); 437 return LOG_LOCAL6; 408 438 } 409 439 -
box/trunk/lib/common/Logging.h
r2417 r2466 203 203 private: 204 204 std::string mName; 205 int mFacility; 205 206 206 207 public: … … 212 213 virtual const char* GetType() { return "Syslog"; } 213 214 virtual void SetProgramName(const std::string& rProgramName); 215 virtual void SetFacility(int facility); 216 static int GetNamedFacility(const std::string& rFacility); 214 217 }; 215 218 … … 261 264 static void SetProgramName(const std::string& rProgramName); 262 265 static std::string GetProgramName() { return sProgramName; } 266 static void SetFacility(int facility); 263 267 264 268 class Guard -
box/trunk/lib/server/Daemon.cpp
r2460 r2466 481 481 mapConfiguration->GetSubConfiguration("Server")); 482 482 483 if(serverConfig.KeyExists("LogFacility")) 484 { 485 std::string facility = 486 serverConfig.GetKeyValue("LogFacility"); 487 Logging::SetFacility(Syslog::GetNamedFacility(facility)); 488 } 489 483 490 // Open PID file for writing 484 491 pidFileName = serverConfig.GetKeyValue("PidFile"); -
box/trunk/lib/server/Daemon.h
r2356 r2466 106 106 #define DAEMON_VERIFY_SERVER_KEYS \ 107 107 ConfigurationVerifyKey("PidFile", ConfigTest_Exists), \ 108 ConfigurationVerifyKey("LogFacility", 0), \ 108 109 ConfigurationVerifyKey("User", ConfigTest_LastEntry) 109 110
Note: See TracChangeset
for help on using the changeset viewer.
