]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_operlog.cpp
Update wiki links to use HTTPS and point to the correct pages.
[user/henk/code/inspircd.git] / src / modules / m_operlog.cpp
index d8006d9d5267d1fa8a68a03b52e9b9ad4e98028a..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)
        {
@@ -58,7 +64,10 @@ class ModuleOperLog : public Module
                                std::string line;
                                if (!parameters.empty())
                                        line = irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined();
-                               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(), line.c_str());
+                               std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + line;
+                               ServerInstance->Logs->Log("m_operlog", DEFAULT, "OPERLOG: " + msg);
+                               if (tosnomask)
+                                       ServerInstance->SNO->WriteGlobalSno('r', msg);
                        }
                }