summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-06-20 23:25:46 -0400
committerAdam <Adam@anope.org>2011-06-20 23:25:46 -0400
commit2667f9046ecd656f805d85397c27b8f19c864112 (patch)
treed2b62efaa017376d680c31a78894524a00c7b2e7 /src
parenta3d0ab3d09cbb636b680ab5015646ccb3200a70c (diff)
Cleaned up some of the logger code which fixes not logging debug logs to files etc when debug is enabled, and some other small things
Diffstat (limited to 'src')
-rw-r--r--src/logger.cpp82
-rw-r--r--src/servers.cpp2
-rw-r--r--src/sockets.cpp4
3 files changed, 32 insertions, 56 deletions
diff --git a/src/logger.cpp b/src/logger.cpp
index 4ccfa813f..d4d09565c 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -205,74 +205,53 @@ void LogInfo::AddType(std::list<Anope::string> &list, const Anope::string &type)
list.push_back(type);
}
-bool LogInfo::HasType(std::list<Anope::string> &list, const Anope::string &type) const
+bool LogInfo::HasType(LogType ltype, const Anope::string &type) const
{
- for (std::list<Anope::string>::iterator it = list.begin(), it_end = list.end(); it != it_end; ++it)
- {
- Anope::string cat = *it;
- bool inverse = false;
- if (cat[0] == '~')
- {
- cat.erase(cat.begin());
- inverse = true;
- }
- if (Anope::Match(type, cat))
- {
- return !inverse;
- }
- }
-
- return false;
-}
-
-std::list<Anope::string> &LogInfo::GetList(LogType type)
-{
- static std::list<Anope::string> empty;
-
- switch (type)
- {
- case LOG_ADMIN:
- return this->Admin;
- case LOG_OVERRIDE:
- return this->Override;
- case LOG_COMMAND:
- return this->Commands;
- case LOG_SERVER:
- return this->Servers;
- case LOG_CHANNEL:
- return this->Channels;
- case LOG_USER:
- return this->Users;
- case LOG_NORMAL:
- return this->Normal;
- default:
- return empty;
- }
-}
-
-bool LogInfo::HasType(LogType type)
-{
- switch (type)
+ const std::list<Anope::string> *list = NULL;
+ switch (ltype)
{
case LOG_ADMIN:
+ list = &this->Admin;
case LOG_OVERRIDE:
+ list = &this->Override;
case LOG_COMMAND:
+ list = &this->Commands;
case LOG_SERVER:
+ list = &this->Servers;
case LOG_CHANNEL:
+ list = &this->Channels;
case LOG_USER:
+ list = &this->Users;
case LOG_NORMAL:
- return !this->GetList(type).empty();
+ list = &this->Normal;
case LOG_TERMINAL:
return true;
case LOG_RAWIO:
return debug ? true : this->RawIO;
case LOG_DEBUG:
return debug ? true : this->Debug;
- // LOG_DEBUG_[234]
default:
break;
}
+ if (list == NULL)
+ return false;
+
+ for (std::list<Anope::string>::const_iterator it = list->begin(), it_end = list->end(); it != it_end; ++it)
+ {
+ Anope::string cat = *it;
+ bool inverse = false;
+ if (cat[0] == '~')
+ {
+ cat.erase(cat.begin());
+ inverse = true;
+ }
+ if (Anope::Match(type, cat))
+ {
+ return !inverse;
+ }
+ }
+
return false;
}
@@ -282,10 +261,7 @@ void LogInfo::ProcessMessage(const Log *l)
if (!l)
throw CoreException("Bad values passed to LogInfo::ProcessMessages");
-
- if (!this->HasType(l->Type))
- return;
- else if (!this->HasType(this->GetList(l->Type), l->Category))
+ else if (!this->HasType(l->Type, l->Category))
return;
if (!this->Sources.empty())
diff --git a/src/servers.cpp b/src/servers.cpp
index 2a9dd7911..19140c154 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -323,7 +323,7 @@ Server *Server::Find(const Anope::string &name, Server *s)
if (!s)
s = Me;
- if (s->GetName().equals_cs(name) || s->GetSID().equals_cs(name))
+ if (s->GetName().equals_ci(name) || s->GetSID().equals_cs(name))
return s;
if (!s->GetLinks().empty())
diff --git a/src/sockets.cpp b/src/sockets.cpp
index f255a4edf..7765d3066 100644
--- a/src/sockets.cpp
+++ b/src/sockets.cpp
@@ -282,10 +282,10 @@ ClientSocket *SocketIO::Accept(ListenSocket *s)
int newsock = accept(s->GetFD(), &conaddr.sa, &size);
#ifndef INVALID_SOCKET
-# define INVALID_SOCKET 0
+# define INVALID_SOCKET -1
#endif
- if (newsock > 0 && newsock != INVALID_SOCKET)
+ if (newsock >= 0 && newsock != INVALID_SOCKET)
return s->OnAccept(newsock, conaddr);
else
throw SocketException("Unable to accept connection: " + Anope::LastError());