Server Log - Lua Errors, Chat, Timestamps

I’m looking for someone to make a script that creates log files which will pick up all lua errors from the server, even while nobody is in there, as well as chat messages sent by players. I want the lua errors to show up as they would in the console and I want chat messages to come out like this:

[Time] STEAMID | Name: Chat message

So if my Steam ID was STEAM_0:0:100500100, my name was Billy Bob Joe, and my message was Pressed the elevator button. and I said this at 01:23:45 PM (hh:mm:ss), the log would print…

[01:23:45 PM] STEAM_0:0:100500100 | Billy Bob Joe: Pressed the elevator button.

Of course, I need timestamps for lua errors too. So if my error was Hook ‘Vcu_HideVehicleHud’ Failed: [autorun\client\cl_vcu.lua:248] attempt to index field ‘Entity’ (a nil value), then I want it to show up like this, on the same line as the error:

[01:23:45 PM] Hook 'Vcu_HideVehicleHud' Failed: [autorun\client\cl_vcu.lua:248] attempt to index field 'Entity' (a nil value)

The reason I want this specifically is because I need a way to log errors as they happen and I would like to go on the server at times and enter chat messages as a commentary so I know what I just did, so if an error is popping up that I’m not seeing for some reason, it will show up in the log and I will have a commentary message explaining what action caused said error.

Source logging does not pick up lua errors and it doesn’t pick up chat messages nor does it pick up much of anything at all and I cannot use ULX because it is incompatible with my operation. Or at least it apparently doesn’t pick up lua errors, because it’s only picking up some hardly important crap that could in no way be interfering with the fact that I am currently running a broken gamemode and there’s no errors to show for it.

I would like these log files to show up in the data folder, titled like this: Saturday 31-12-2011.txt
As today is Saturday, it is the thirty first day of the twelfth month of the year, and it is 2011. DD:MM:YY format.

Thank you for your time.

Requires gm_luaerror


local function ErrorLog(text)
file.Append("%A %d-%m-%y")…".txt","["…"%H:%M:%S %p")…"] “…text…”


ErrorLog(ply:SteamID()…" | “…ply:Nick()…”: "…text)

I put the .dll in the right place, but where does this lua file go? I tried autorun/server, it doesn’t seem to be creating files anywhere.

It should work in autorun/server. Are there any errors when the server starts up?

filex is deprecated, file.Append exists now.

Thanks, I didn’t know it was available outside the beta.

I updated the file but I still can’t seem to find where the log files are being stored.

They should be in garrysmod/data.

filex.Append just returns a file.Append now, for compatibility reasons

The file doesn’t seem to be in there. I looked in the lua file and it doesn’t seem as if there’s any clarification that the file is to be sent anywhere specific, though I wouldn’t know. A mysterious file popped up in garrysmod/garrysmod named lua_errors_server.txt but it wasn’t tied with this file, as it was lua errors that were relevant to a time before I installed this script, and it didn’t use the syntax that I saw you told the script to use in the file that you made. I looked in every one of the server’s folders and still couldn’t file the error file that’s meant to be printing. :frowning:

Perhaps your server has no errors?

When the entire gamemode is broken, there must be an error. I know there is an error that comes up when gamemodes aren’t recognized and therefore not run, just replaced with base gamemode, which is one of the problems I’m having.

Try going in and typing something, see if it logs.

I already tried such. My problem isn’t that it’s not logging anything in a file that I can locate, my problem is that I can’t find where the file is.

Whats in your garrysmod/data folder?

[editline]8th January 2012[/editline]

Are you sure you are connected to the right FTP server?

Nothing but the usual, and I must be connected to the right one. I only have one to begin with.

You restarted your server and are checking the code on your server and not your client?

Try running this in the server console:

lua_run require("luaerror")

It’s giving me this error on my server:

Error loading module 'luaerror' from file 'e:\srcds\orangebox\garrysmod\lua\includes\modules\gm_luaerror.dll':
	%1 is not a valid Win32 application.

file.Append won’t work till the actual file is created. You need to first do file.Write( file, “” ), then file.Append will work.

file.Append creates the file if it doesn’t exist.