The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

LogManager Class Reference

#include <logger.h>

Inheritance diagram for LogManager:

Inheritance graph
[legend]
Collaboration diagram for LogManager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 LogManager (InspIRCd *Instance)
void SetupNoFork ()
 Sets up the logstream for -nofork.
void AddLoggerRef (FileWriter *fw)
 Adds a FileWriter instance to LogManager, or increments the reference count of an existing instance.
void DelLoggerRef (FileWriter *fw)
 Indicates that a FileWriter reference has been removed.
void OpenFileLogs ()
 Opens all logfiles defined in the configuration file using <log method="file">.
void CloseLogs ()
 Removes all LogStreams, meaning they have to be readded for logging to continue.
void AddLogTypes (const std::string &type, LogStream *l, bool autoclose)
 Adds a single LogStream to multiple logtypes.
bool AddLogType (const std::string &type, LogStream *l, bool autoclose)
 Registers a new logstream into the logging core, so it can be called for future events It is not a good idea to mix values of autoclose for the same LogStream.
void DelLogStream (LogStream *l)
 Removes a logstream from the core.
bool DelLogType (const std::string &type, LogStream *l)
 Removes a LogStream from a single type.
void Log (const std::string &type, int loglevel, const std::string &msg)
 Logs an event, sending it to all LogStreams registered for the type.
void Log (const std::string &type, int loglevel, const char *fmt,...) CUSTOM_PRINTF(4
 Logs an event, sending it to all LogStreams registered for the type.

Private Attributes

bool Logging
 Lock variable, set to true when a log is in progress, which prevents further loggging from happening and creating a loop.
LogStreamnoforkstream
 LogStream for -nofork, logs to STDOUT when it's active.
InspIRCdServerInstance
std::map< std::string, std::vector<
LogStream * > > 
LogStreams
 Map of active log types and what LogStreams will receive them.
std::map< LogStream *, int > AllLogStreams
 Refcount map of all LogStreams managed by LogManager.
std::map< LogStream *, std::vector<
std::string > > 
GlobalLogStreams
 LogStreams with type * (which means everything), and a list a logtypes they are excluded from (eg for "* -USERINPUT -USEROUTPUT").
FileLogMap FileLogs
 Refcounted map of all FileWriters in use by FileLogStreams, for file stream sharing.

Detailed Description

Definition at line 126 of file logger.h.


Constructor & Destructor Documentation

LogManager::LogManager InspIRCd Instance  )  [inline]
 

Definition at line 158 of file logger.h.

References ServerInstance.


Member Function Documentation

void LogManager::AddLoggerRef FileWriter fw  )  [inline]
 

Adds a FileWriter instance to LogManager, or increments the reference count of an existing instance.

Used for file-stream sharing for FileLogStreams.

Definition at line 174 of file logger.h.

Referenced by FileLogStream::FileLogStream().

bool LogManager::AddLogType const std::string type,
LogStream l,
bool  autoclose
 

Registers a new logstream into the logging core, so it can be called for future events It is not a good idea to mix values of autoclose for the same LogStream.

Parameters:
type The type to add this LogStream to.
l The LogStream to add.
autoclose True to have the LogStream automatically closed when all references to it are removed from LogManager. False to leave it open.
Returns:
True if the LogStream was added successfully, False otherwise.

Definition at line 176 of file logger.cpp.

References AllLogStreams, GlobalLogStreams, and LogStreams.

Referenced by AddLogTypes(), InspIRCd::OpenLog(), and SetupNoFork().

void LogManager::AddLogTypes const std::string type,
LogStream l,
bool  autoclose
 

Adds a single LogStream to multiple logtypes.

This automatically handles things like "* -USERINPUT -USEROUTPUT" to mean all but USERINPUT and USEROUTPUT types. It is not a good idea to mix values of autoclose for the same LogStream.

Parameters:
type The type string (from configuration, or whatever) to parse.
l The LogStream to add.
autoclose True to have the LogStream automatically closed when all references to it are removed from LogManager. False to leave it open.

Definition at line 135 of file logger.cpp.

References AddLogType(), DelLogStream(), DelLogType(), irc::sepstream::GetToken(), and GlobalLogStreams.

Referenced by OpenFileLogs().

void LogManager::CloseLogs  ) 
 

Removes all LogStreams, meaning they have to be readded for logging to continue.

Only LogStreams that were listed in AllLogStreams are actually closed.

Definition at line 124 of file logger.cpp.

References AllLogStreams, GlobalLogStreams, and LogStreams.

Referenced by InspIRCd::Cleanup(), and ServerConfig::Read().

void LogManager::DelLoggerRef FileWriter fw  )  [inline]
 

Indicates that a FileWriter reference has been removed.

Reference count is decreased, and if zeroed, the FileWriter is closed.

Definition at line 189 of file logger.h.

Referenced by FileLogStream::~FileLogStream().

void LogManager::DelLogStream LogStream l  ) 
 

Removes a logstream from the core.

After removal, it will not recieve further events. If the LogStream was ever added with autoclose, it will be closed after this call (this means the pointer won't be valid anymore).

Definition at line 212 of file logger.cpp.

References AllLogStreams, GlobalLogStreams, and LogStreams.

Referenced by AddLogTypes().

bool LogManager::DelLogType const std::string type,
LogStream l
 

Removes a LogStream from a single type.

If the LogStream has been registered for "*" it will still receive the type unless you remove it from "*" specifically. If the LogStream was added with autoclose set to true, then when the last occurrence of the stream is removed it will automatically be closed (freed).

Definition at line 238 of file logger.cpp.

References AllLogStreams, GlobalLogStreams, and LogStreams.

Referenced by AddLogTypes().

void LogManager::Log const std::string type,
int  loglevel,
const char *  fmt,
  ...
 

Logs an event, sending it to all LogStreams registered for the type.

Parameters:
type Log message type (ex: "USERINPUT", "MODULE", ...)
loglevel Log message level (DEBUG, VERBOSE, DEFAULT, SPARSE, NONE)
msg The format of the message to be logged. See your C manual on printf() for details.

Definition at line 284 of file logger.cpp.

References Log(), and Logging.

void LogManager::Log const std::string type,
int  loglevel,
const std::string msg
 

Logs an event, sending it to all LogStreams registered for the type.

Parameters:
type Log message type (ex: "USERINPUT", "MODULE", ...)
loglevel Log message level (DEBUG, VERBOSE, DEFAULT, SPARSE, NONE)
msg The message to be logged (literal).

Definition at line 301 of file logger.cpp.

References GlobalLogStreams, Logging, and LogStreams.

Referenced by ListenSocketBase::AcceptInternal(), ModeChannelBan::AddBan(), ModuleSQLite3::AddConn(), ModulePgSQL::AddConn(), ModuleMsSQL::AddConn(), ModuleFilter::AddFilter(), DNS::AddResolverClass(), UserManager::AddUser(), CullList::Apply(), BufferedSocket::BindAddr(), InspIRCd::BindPorts(), InspIRCd::BindSocket(), ModuleHTTPAccessList::BlockAccess(), BufferedSocket::BufferedSocket(), InspIRCd::BufferedSocketCull(), ModeHandler::ChangeCount(), InspIRCd::CheckDie(), InspIRCd::CheckRoot(), SQLConn::Close(), IdentRequestSocket::Close(), BufferedSocket::Close(), ServerConfig::ConfValue(), ConnectDatabases(), CommandParser::CreateCommand(), InspIRCd::DaemonSeed(), User::DecrementModes(), XLine::DefaultApply(), ModeChannelBan::DelBan(), DNS::DNS(), SQLConn::DoConnect(), BufferedSocket::DoConnect(), DoConnect(), SpanningTreeUtilities::DoFailOver(), DoneConnect(), SQLConn::DoQuery(), error_callback(), CommandParser::FindSym(), Snomask::Flush(), BufferedSocket::FlushWriteBuffer(), TreeSocket::ForceJoin(), TreeSocket::ForceMode(), User::FullConnect(), ModuleSSLGnuTLS::GenerateDHParams(), User::GetBuffer(), BanCacheManager::GetHit(), SQLConn::HandleError(), IdentRequestSocket::HandleEvent(), ListenSocketBase::HandleEvent(), DNS::HandleEvent(), ModuleSafeList::HandleList(), ModuleSpanningTree::HandleMap(), SQLConn::HandleMessage(), User::HasPrivPermission(), TreeSocket::Inbound_Server(), InitConnect(), InspIRCd::InspIRCd(), BufferedSocket::InternalMarkConnected(), Channel::IsExtBanned(), Channel::JoinUser(), ListenSocketBase::ListenSocketBase(), ModuleManager::Load(), ModuleManager::LoadAll(), CommandParser::LoadCommand(), ServerConfig::LoadConf(), Log(), ModuleSQLOper::LoginFail(), ModuleSQLOper::LookupOper(), TreeSocket::MakePass(), ModuleRIPEMD160::MDinit(), ModuleMsSQL::ModuleMsSQL(), ModuleSASL::ModuleSASL(), ModuleSQL::ModuleSQL(), ModuleSQLite3::ModuleSQLite3(), ModuleXLineDB::OnAddLine(), ModuleTestClient::OnBackgroundTimer(), ModuleSQLutils::OnChannelDelete(), ModuleIdent::OnCheckReady(), IdentRequestSocket::OnConnected(), HttpServerSocket::OnDataReady(), SecurityIPResolver::OnError(), SQLresolver::OnError(), ModuleSpanningTree::OnEvent(), ModuleSASL::OnEvent(), ModuleHttpStats::OnEvent(), ModuleHTTPAccessList::OnEvent(), ModuleConnectBan::OnGarbageCollect(), ModuleSQLOper::OnLoadModule(), ModuleOperHash::OnLoadModule(), UserResolver::OnLookupComplete(), ModuleSpanningTree::OnPostCommand(), ModuleOperSSLCert::OnPreCommand(), ModuleOperLog::OnPreCommand(), ModuleSSLOpenSSL::OnRawSocketAccept(), ModuleSSLOpenSSL::OnRawSocketConnect(), ModuleSpanningTree::OnRehash(), ModuleSSLOpenSSL::OnRehash(), ModuleSSLGnuTLS::OnRehash(), ModulePermanentChannels::OnRehash(), ModuleChanLog::OnRehash(), ModuleCgiIRC::OnRehash(), ModuleTestClient::OnRequest(), ModuleRIPEMD160::OnRequest(), ModuleFoobar::OnUserConnect(), ModuleSQLutils::OnUserDisconnect(), ModuleFoobar::OnUserJoin(), ModuleFoobar::OnUserPart(), ModuleAlias::OnUserPreMessage(), FilterBase::OnUserPreNotice(), ModuleFoobar::OnUserQuit(), ModuleIdent::OnUserRegister(), User::Oper(), TreeSocket::ParseUID(), PCRERegex::PCRERegex(), CommandParser::ProcessBuffer(), SaslAuthenticator::ProcessInboundMessage(), TreeSocket::ProcessLine(), User::PurgeEmptyChannels(), SQLConn::Query(), UserManager::QuitUser(), TreeSocket::RandString(), BufferedSocket::Read(), ServerConfig::Read(), ModulePgSQL::ReadConf(), ModuleBlockCAPS::ReadConf(), ModuleHTTPAccessList::ReadConfig(), SpanningTreeUtilities::ReadConfiguration(), ModuleXLineDB::ReadDatabase(), ServerConfig::ReadFile(), ModuleFilter::ReadFilters(), IdentRequestSocket::ReadResponse(), SpanningTreeUtilities::RefreshIPCache(), DNS::Rehash(), BanCacheManager::RemoveEntries(), BanCacheManager::RemoveHit(), ModuleXLineDB::RemoveLine(), ServerConfig::ReportConfigError(), Resolver::Resolver(), ModuleRIPEMD160::RMD(), InspIRCd::Run(), DNSRequest::SendRequests(), User::SetClass(), Channel::SetDefaultModes(), TreeServer::SetID(), User::SetSockAddr(), ModuleSpanningTree::ShowMap(), SpanningTreeUtilities::SpanningTreeUtilities(), SQLConn::SQLConn(), TreeSocket::Squit(), User::StartDNSLookup(), SocketTimeout::Tick(), TreeServer::TreeServer(), ModuleManager::Unload(), User::User(), ValidateDnsServer(), ValidateMaxConn(), ValidateMaxTargets(), ValidateMaxWho(), ValidateNetBufferSize(), ValidateServerName(), ValidateSID(), ValidateSoftLimit(), ValidateWhoWas(), User::Write(), ModuleXLineDB::WriteDatabase(), TreeSocket::WriteLine(), UserManager::WriteMode(), InspIRCd::WritePID(), ListenSocketBase::~ListenSocketBase(), and User::~User().

void LogManager::OpenFileLogs  ) 
 

Opens all logfiles defined in the configuration file using <log method="file">.

Definition at line 61 of file logger.cpp.

References AddLogTypes(), Conf, InspIRCd::Config, DEBUG, ServerConfig::debugging, DEFAULT, ServerConfig::forcedebug, ServerConfig::nofork, NONE, ConfigReader::ReadValue(), ServerInstance, SetupNoFork(), SPARSE, VERBOSE, and ServerConfig::writelog.

Referenced by ServerConfig::Read().

void LogManager::SetupNoFork  ) 
 

Sets up the logstream for -nofork.

Called by InspIRCd::OpenLog() and LogManager::OpenFileLogs(). First time called it creates the nofork stream and stores it in noforkstream. Each call thereafter just readds it to GlobalLogStreams and updates the loglevel.

Definition at line 47 of file logger.cpp.

References AddLogType(), LogStream::ChangeLevel(), InspIRCd::Config, DEBUG, DEFAULT, ServerConfig::forcedebug, noforkstream, and ServerInstance.

Referenced by OpenFileLogs(), and InspIRCd::OpenLog().


Member Data Documentation

std::map<LogStream *, int> LogManager::AllLogStreams [private]
 

Refcount map of all LogStreams managed by LogManager.

If a logstream is not listed here, it won't be automatically closed by LogManager, even if it's loaded in one of the other lists.

Definition at line 146 of file logger.h.

Referenced by AddLogType(), CloseLogs(), DelLogStream(), and DelLogType().

FileLogMap LogManager::FileLogs [private]
 

Refcounted map of all FileWriters in use by FileLogStreams, for file stream sharing.

Definition at line 154 of file logger.h.

std::map<LogStream *, std::vector<std::string> > LogManager::GlobalLogStreams [private]
 

LogStreams with type * (which means everything), and a list a logtypes they are excluded from (eg for "* -USERINPUT -USEROUTPUT").

Definition at line 150 of file logger.h.

Referenced by AddLogType(), AddLogTypes(), CloseLogs(), DelLogStream(), DelLogType(), and Log().

bool LogManager::Logging [private]
 

Lock variable, set to true when a log is in progress, which prevents further loggging from happening and creating a loop.

Definition at line 131 of file logger.h.

Referenced by Log().

std::map<std::string, std::vector<LogStream *> > LogManager::LogStreams [private]
 

Map of active log types and what LogStreams will receive them.

Definition at line 141 of file logger.h.

Referenced by AddLogType(), CloseLogs(), DelLogStream(), DelLogType(), and Log().

LogStream* LogManager::noforkstream [private]
 

LogStream for -nofork, logs to STDOUT when it's active.

Definition at line 135 of file logger.h.

Referenced by SetupNoFork().

InspIRCd* LogManager::ServerInstance [private]
 

Definition at line 137 of file logger.h.

Referenced by OpenFileLogs(), and SetupNoFork().


The documentation for this class was generated from the following files: