]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_operlog.cpp
Fix mistakenly using Clang instead of GCC on older FreeBSD versions.
[user/henk/code/inspircd.git] / src / modules / m_operlog.cpp
index cc533dbf5de7cb54e211fe85c77d205279f1ffd5..edb9109e89f246d0cde5089655c1ae7279d0c7c6 100644 (file)
 
 class ModuleOperLog : public Module
 {
- private:
+       bool tosnomask;
 
  public:
-       ModuleOperLog()         {
-
-               Implementation eventlist[] = { I_OnPreCommand, I_On005Numeric };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
+       void init()
+       {
+               Implementation eventlist[] = { I_OnPreCommand, I_On005Numeric, I_OnRehash };
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
+               ServerInstance->SNO->EnableSnomask('r', "OPERLOG");
+               OnRehash(NULL);
        }
 
        virtual ~ModuleOperLog()
@@ -43,6 +45,10 @@ class ModuleOperLog : public Module
                return Version("A module which logs all oper commands to the ircd log at default loglevel.", VF_VENDOR);
        }
 
+       void OnRehash(User* user)
+       {
+               tosnomask = ServerInstance->Config->ConfValue("operlog")->getBool("tosnomask", false);
+       }
 
        virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line)
        {
@@ -54,7 +60,15 @@ class ModuleOperLog : public Module
                {
                        Command* thiscommand = ServerInstance->Parser->GetHandler(command);
                        if ((thiscommand) && (thiscommand->flags_needed == 'o'))
-                               ServerInstance->Logs->Log("m_operlog",DEFAULT,"OPERLOG: [%s!%s@%s] %s %s",user->nick.c_str(), user->ident.c_str(), user->host.c_str(), command.c_str(), parameters.empty() ? "" : irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined().c_str());
+                       {
+                               std::string line;
+                               if (!parameters.empty())
+                                       line = irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined();
+                               std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + line;
+                               ServerInstance->Logs->Log("m_operlog", DEFAULT, "OPERLOG: " + msg);
+                               if (tosnomask)
+                                       ServerInstance->SNO->WriteGlobalSno('r', msg);
+                       }
                }
 
                return MOD_RES_PASSTHRU;