OnLuaError Logging

hi, i just want to log some gamemode errors in a file

is it possible via hook/log (file)? (not menu state)

i know about lua_error_url, but i want to filter it before and need to make a different http.post

best would be a hook to get the errors from server and client (not menu state)
or a file where they get saved

with
lua_log_sv 1
lua_log_cl 1
i get the errors in a file, but it gets bigger and bigger and only the server owner can “remove that file”/“empty it”

would be better if the log txt file gets removed after some time, only containing the latest errors

Edit:
also debug.getregistry()[1] should be the error function but i dont know how to make it work
if someone knows how to make it work, please let me know :smiley:

This should please you.

2 Likes

i tried that, but doesn’t seem to work or i dont know how to use that :smiley:
but thanks for the response

Here is my currently working implementation: Allows to handle errors in a customized way and without going through the default features of Garry's Mod. · GitHub (serverside). I have been using it for years without any issues.

1 Like

that helped a lot, thanks

actually when i hooked inside this, it broke the error function

but when i put the hook.run in a timer it is working without any problems

works on server and client

I’ve never experienced this issue, but from looking around the Gmod Discord, it seems that you need to use pcall if you want to use hook.Call or hook.Run. Here are some examples:

i think i dont to much in my hooks that it took to long for the error function
so a timer removed that problem
maybe pcall also does that fix
thanks for that info :smiley: