RCON logging

tarynkelley

Retired Staff
Retired Staff
Trusted Member
Nov 14, 2015
575
178
28
Parts Unknown
Is there any way to log the executed RCON commands? They show up in the console, but don't get logged.
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
I don't know how much this will log or even if it will log RCON commands, But here you go
Python:
__title__ = 'ConsoleLogger'
__author__ = 'Jakkee'
__version__ = '1.0'

import clr
clr.AddReferenceByName("Fougerite")
import Fougerite

class ConsoleLogger:
    def On_Console(self, Player, ConsoleEvent):
        if not Plugin.IniExists("Log"):
            Plugin.CreateIni("Log").Save()
        command = ConsoleEvent.Class
        if ConsoleEvent.Function is not None:
            command = ConsoleEvent.Class + "." + ConsoleEvent.Function
        ini = Plugin.GetIni("Log")
        ini.AddSetting("Log", Plugin.GetDate() + "|" + Plugin.GetTime(), Player.Name + "=" + Player.SteamID + " has run: " + command)
 

tarynkelley

Retired Staff
Retired Staff
Trusted Member
Nov 14, 2015
575
178
28
Parts Unknown
[4/4/2016 1:09:52 AM] [Error] [IronPython] Error in plugin ConsoleLogger:
[4/4/2016 1:09:52 AM] [Error] Traceback (most recent call last):
File "<string>", line 17, in On_Console
AttributeError: 'NoneType' object has no attribute 'Name'
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
[4/4/2016 1:09:52 AM] [Error] [IronPython] Error in plugin ConsoleLogger:
[4/4/2016 1:09:52 AM] [Error] Traceback (most recent call last):
File "<string>", line 17, in On_Console
AttributeError: 'NoneType' object has no attribute 'Name'
hmm..
Try this, it will not through errors but it also may not log anything as well
Python:
__title__ = 'ConsoleLogger'
__author__ = 'Jakkee'
__version__ = '1.0'

import clr
clr.AddReferenceByName("Fougerite")
import Fougerite

class ConsoleLogger:
    def On_Console(self, Player, ConsoleEvent):
        try:
            if not Plugin.IniExists("Log"):
                Plugin.CreateIni("Log").Save()
            command = ConsoleEvent.Class
            if ConsoleEvent.Function is not None:
                command = ConsoleEvent.Class + "." + ConsoleEvent.Function
            ini = Plugin.GetIni("Log")
            ini.AddSetting("Log", Plugin.GetDate() + "|" + Plugin.GetTime(), Player.Name + "=" + Player.SteamID + " has run: " + command)      
        except:
            pass
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
hmm..
Try this, it will not through errors but it also may not log anything as well
Python:
__title__ = 'ConsoleLogger'
__author__ = 'Jakkee'
__version__ = '1.0'

import clr
clr.AddReferenceByName("Fougerite")
import Fougerite

class ConsoleLogger:
    def On_Console(self, Player, ConsoleEvent):
        try:
            if not Plugin.IniExists("Log"):
                Plugin.CreateIni("Log").Save()
            command = ConsoleEvent.Class
            if ConsoleEvent.Function is not None:
                command = ConsoleEvent.Class + "." + ConsoleEvent.Function
            ini = Plugin.GetIni("Log")
            ini.AddSetting("Log", Plugin.GetDate() + "|" + Plugin.GetTime(), Player.Name + "=" + Player.SteamID + " has run: " + command)      
        except:
            pass
Use Plugin.Log("LogName", x) instead of da iniminis.

Sent From My Samsung Galaxy S4
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
I didn't even add ini.Save() lol... But heres the Plugin.Log() :)
Python:
__title__ = 'ConsoleLogger'
__author__ = 'Jakkee'
__version__ = '1.0'

import clr
clr.AddReferenceByName("Fougerite")
import Fougerite

class ConsoleLogger:
    def On_Console(self, Player, ConsoleEvent):
        try:
            command = ConsoleEvent.Class
            if ConsoleEvent.Function is not None:
                command = ConsoleEvent.Class + "." + ConsoleEvent.Function
            Plugin.Log("Log", Player.Name + "=" + Player.SteamID + " has run: " + command)      
        except:
            pass
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Doesn't really log anything, Only random stuff that are not commands.
E.G Test.Test True, blah, blah.blah
Inv.give /env.time / sendrate etc aren't logged.