Warning and Error Logging system

Hello, I would like to know how you get all Roblox errors like the developer console so you can use them. I would like to make a system that notifies the server if a client has a error or warning, or if the server has a warning or error. This is so I can use Discord Web hooks to send any error info in runtime to a debug discord server to see any problems as they come about. Thanks in advance, Rex

You dont need to give me the code, only a API reference

3 Likes

I’ve heard people saying something against using Discord’s webhooks as a logging service.


Found this post:

2 Likes

Yes I know, but I do not want to use all of that, when I always use discord, I have it on my phone, the developers I work with have it, and I find it overall easier. I only want simple error logging that I will get a notification for and dont have to download anything or make a account for anything I dont have

Found a previous topic similar. They stated that Discord shouldn’t be used for logging. Clearly they state that webhooks connected to Roblox is killing Discord’s bandwidth. Better use alternatives.


On a side note, keep your rates low for sure. Otherwise you’ll be hauling trouble from Discord.

Well, you can get a script’s error via the service ScriptContext.

game:GetService("ScriptContext").Error:Connect(function(Error)
    print(Error)
end)
6 Likes

Discord is providing public web hooks, I have never had a big issue with invalid requests, and will not decide not to use it because its using bandwidth, every alternative uses bandwidth, the discord route just suits me best. I have only asked for how to get error and warning information from the server and clients, I did not ask for a discussion about weather I should use discord web hooks for logging the data.

Well if you insist…

local HttpService = game:GetService("HttpService")
local ScriptContext = game:GetService("ScriptContext")

local webhook = "https://discordapp.com/api/webhooks" -- fill here

ScriptContext.Error:Connect(function(Error)
    local payload = {
        content = Error
    }

    HttpService:PostAsync(webhook, payload)
end)

First time I actually do touch the PostAsync I must say.

3 Likes

Thank you, and for your concerns about overloading discord, this system will not run in studio.

Ah, crap forgot to JSONEncode.

local HttpService = game:GetService("HttpService")
local ScriptContext = game:GetService("ScriptContext")

local webhook = "https://discordapp.com/api/webhooks" -- fill here

ScriptContext.Error:Connect(function(Error)
    local payload = HttpService:JSONEncode({
        username = "Error";
        content = Error;
    })

    HttpService:PostAsync(webhook, payload)
end)
7 Likes

From my experience you need to JSON encode the payload and have two things.
[“username”], which is the name of it.
[“content”], which holds the error.
If I forgot something, oops.
Like this:

["username"] = "yes";
["content"] = "error";
1 Like

No, I know how to send the data to discord, I know how to do it reliably. But thank you for providing the HTTP sending help

1 Like

As Operatik said, it’s not wise to use Discord webhooks for error reporting. My team uses Sentry, which is a service entirely dedicated to error reporting. I can’t help with the network code because it’s not my area of expertise, but I figured I’d give you the option.

cc @tomgie

Yeah, if your error logging gets recognized, you will be banned from Discord.

and for your concerns about overloading discord, this system will not run in studio.

Yeah, and when you have an error and multiple servers, you will be spamming that webhook. There are much better solutions that don’t risk your Discord account and provide better resources with analytics on what’s happening.

(I just realized I replied to the wrong person… sorry! This is meant for OP)

1 Like

Discord is not an error logging service and your account will be disabled for using it as such.

Use GoogleAnalytics, GameAnalytics, Sentry or one of the many alternatives.

3 Likes

I have not seen anything about not being allowed to use discord web hooks for error logging, did you mean you think I will go over discords web hook limits? I have not been able to find anything about allowed use cases for discord web hooks.

Discord previously blocked requests directly to their API from a Roblox server, as seen here: x.com

There were proxies provided that helped limit the abuse of Discord’s API, and eventually Discord let up on it because people still wanted it for other uses. It is still a violation of their ToS.

I would like to kindly suggest you heed the previous posts warnings about using Discord for logging errors and warnings as it has already been officially stated by roblox if you do use discord as your error logging container, you will be disabled.
image
Also, we do not want a repeat of the ban.

1 Like

Yes, but that is just about the API limits, not about a certain use case

Please understand this that your Discord account will be in the risk zone of being disabled when violating the ToS as previously mentioned by replies above.

If you create a game and it gets popular, you are certainly going to hit the discord call limit. Even though you seem to not care about getting banned or care about what we say, I still recommend that you go with something such as Sentry. Sentry has the benefit of also organizing your games and the errors it receives. Plus it’s free for a specific number of requests.

2 Likes