mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Implement LogManager::CloseLogs() to give logstreams a chance to clean up on rehash or exit.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8863 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
1af394d68b
commit
bfff1d9d93
@ -558,10 +558,6 @@ class CoreExport InspIRCd : public classbase
|
||||
*/
|
||||
bool OpenLog(char** argv, int argc);
|
||||
|
||||
/** Close the currently open log file
|
||||
*/
|
||||
void CloseLog();
|
||||
|
||||
/** Return true if a channel name is valid
|
||||
* @param chname A channel name to verify
|
||||
* @return True if the name is valid
|
||||
|
@ -41,6 +41,7 @@ class CoreExport LogManager : public classbase
|
||||
ServerInstance = Instance;
|
||||
}
|
||||
|
||||
void CloseLogs();
|
||||
bool AddLogType(const std::string &type, LogStream *l);
|
||||
bool DelLogType(const std::string &type, LogStream *l);
|
||||
void Log(const std::string &type, int loglevel, const std::string &msg);
|
||||
|
@ -34,7 +34,7 @@ CmdResult CommandRehash::Handle (const char** parameters, int pcnt, User *user)
|
||||
else
|
||||
{
|
||||
ServerInstance->SNO->WriteToSnoMask('A', "%s is rehashing config file %s",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
|
||||
ServerInstance->CloseLog();
|
||||
ServerInstance->Logs->CloseLogs();
|
||||
if (!ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc))
|
||||
user->WriteServ("*** NOTICE %s :ERROR: Could not open logfile %s: %s", user->nick, ServerInstance->Config->logpath.c_str(), strerror(errno));
|
||||
ServerInstance->RehashUsersAndChans();
|
||||
|
@ -103,7 +103,7 @@ void InspIRCd::Cleanup()
|
||||
}
|
||||
|
||||
/* Close logging */
|
||||
// XXX we need to add a method to terminate all logstreams.
|
||||
this->Logs->CloseLogs();
|
||||
|
||||
/* Cleanup Server Names */
|
||||
for(servernamelist::iterator itr = servernames.begin(); itr != servernames.end(); ++itr)
|
||||
@ -178,11 +178,6 @@ void InspIRCd::RehashUsersAndChans()
|
||||
delete old_chans;
|
||||
}
|
||||
|
||||
void InspIRCd::CloseLog()
|
||||
{
|
||||
// XXX add a method to terminate all logstreams.
|
||||
}
|
||||
|
||||
void InspIRCd::SetSignals()
|
||||
{
|
||||
#ifndef WIN32
|
||||
|
@ -42,6 +42,30 @@
|
||||
*
|
||||
*/
|
||||
|
||||
void LogManager::CloseLogs()
|
||||
{
|
||||
/*
|
||||
* This doesn't remove logstreams from the map/vector etc, because if this is called, shit is hitting the fan
|
||||
* and we're going down anyway - this just provides a "nice" way for logstreams to clean up. -- w
|
||||
*/
|
||||
std::map<std::string, std::vector<LogStream *> >::iterator i;
|
||||
|
||||
while (LogStreams.begin() != LogStreams.end())
|
||||
{
|
||||
i = LogStreams.begin();
|
||||
|
||||
while (i->second.begin() != i->second.end())
|
||||
{
|
||||
std::vector<LogStream *>::iterator it = i->second.begin();
|
||||
|
||||
delete (*it);
|
||||
i->second.erase(it);
|
||||
}
|
||||
|
||||
LogStreams.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
bool LogManager::AddLogType(const std::string &type, LogStream *l)
|
||||
{
|
||||
std::map<std::string, std::vector<LogStream *> >::iterator i = LogStreams.find(type);
|
||||
|
@ -90,7 +90,7 @@ class CommandSwhois : public Command
|
||||
delete metadata;
|
||||
|
||||
// If it's an empty swhois, unset it (not ideal, but ok)
|
||||
if (text.empty())
|
||||
if (text->empty())
|
||||
{
|
||||
dest->Shrink("swhois");
|
||||
delete text;
|
||||
|
@ -47,7 +47,7 @@ void InspIRCd::Exit(int status)
|
||||
void InspIRCd::Rehash()
|
||||
{
|
||||
this->SNO->WriteToSnoMask('A', "Rehashing config file %s due to SIGHUP",ServerConfig::CleanFilename(this->ConfigFileName));
|
||||
this->CloseLog();
|
||||
this->Logs->CloseLogs();
|
||||
if (!this->OpenLog(this->Config->argv, this->Config->argc))
|
||||
this->SNO->WriteToSnoMask('A', "ERROR: Could not open logfile %s: %s", Config->logpath.c_str(), strerror(errno));
|
||||
this->RehashUsersAndChans();
|
||||
|
Loading…
x
Reference in New Issue
Block a user