diff options
| author | 2022-01-18 03:10:47 +0000 | |
|---|---|---|
| committer | 2022-05-01 22:07:04 +0100 | |
| commit | c382faf9c941ad2ab93f806b6477933d41566719 (patch) | |
| tree | 9244cf84190cf74d4e16085b2ae9bc9b5520457f /src/inspircd.cpp | |
| parent | Delete the old logging system. (diff) | |
Rewrite the entire logging system.
- Much cleaner API for writing to the log.
- Adds support for stderr and stdout logging to the core.
- Adds support for sql and syslog logging in modules.
Diffstat (limited to 'src/inspircd.cpp')
| -rw-r--r-- | src/inspircd.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 7caa17a17..5acf3dabf 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -500,13 +500,9 @@ InspIRCd::InspIRCd(int argc, char** argv) << "See " << rang::style::bold << rang::fg::green << "/INFO" << rang::style::reset << " for contributors & authors" << std::endl << std::endl; + Logs.RegisterServices(); if (Config->cmdline.forcedebug) - { - FILE* newstdout = fdopen(dup(STDOUT_FILENO), "w"); - FileWriter* fw = new FileWriter(newstdout, 1); - FileLogStream* fls = new FileLogStream(LOG_RAWIO, fw); - Logs.AddLogTypes("*", fls, true); - } + Logs.EnableDebugMode(); if (!FindConfigFile(ConfigFileName)) { @@ -528,7 +524,17 @@ InspIRCd::InspIRCd(int argc, char** argv) */ this->Config->Read(); this->Config->Apply(NULL, ""); - Logs.OpenFileLogs(); + + try + { + Logs.CloseLogs(); + Logs.OpenLogs(false); + } + catch (const CoreException& ex) + { + std::cout << "ERROR: Cannot open log files: " << ex.GetReason() << std::endl << "Exiting..." << std::endl; + Exit(EXIT_STATUS_LOG); + } // If we don't have a SID, generate one based on the server name and the server description if (Config->sid.empty()) @@ -548,6 +554,17 @@ InspIRCd::InspIRCd(int argc, char** argv) TryBindPorts(); this->Modules.LoadAll(); + try + { + // We reopen logs again after modules to allow module loggers to have a chance to register. + Logs.CloseLogs(); + Logs.OpenLogs(true); + } + catch (const CoreException& ex) + { + std::cout << "ERROR: Cannot open log files: " << ex.GetReason() << std::endl << "Exiting..." << std::endl; + Exit(EXIT_STATUS_LOG); + } std::cout << "InspIRCd is now running as '" << Config->ServerName << "'[" << Config->GetSID() << "] with " << SocketEngine::GetMaxFds() << " max open sockets" << std::endl; |
