PhrozenByte Posted September 11, 2016 Share Posted September 11, 2016 (edited) PhrozenByte Debug is a is a free software utility resource allowing resource developers to add "quiet" debug messages to their resources. MTA's built-in debug mechanism (outputDebugString() function) floods both the server console and log with debug messages - even in productive environments. This bears the danger that a server administrator misses important messages in his server log. This utility resource hooks into MTA's built-in /debugscript command to detect whether a (authorized) player is currently debugging MTA. If this is the case, it passes all debug messages to MTA's outputDebugString() function; otherwise it discards them. Download: https://community.multitheftauto.com/index.php?p=resources&s=details&id=13657 GitHub repository (source code): https://github.com/PhrozenByte/mtasa-debug PhrozenByte Debug exports the following server-side functions: int getDebugLevel() bool log(int level, [ player fromPlayer = nil, ] string message, [ int red = 255, int green = 255, int blue = 255 ]) bool notice([ player fromPlayer = nil, ] string message, [ int red = 255, int green = 255, int blue = 255 ]), warn(…) and error(…) It furthermore exports the following client-side functions: Client-side debugging: int getDebugLevel() bool log(int level, string message, [ int red = 255, int green = 255, int blue = 255 ]) bool notice(string message, [ int red = 255, int green = 255, int blue = 255 ]), warn(…) and error(…) Server-side debugging: void requestServerDebugLevel([ element callbackElement = resourceRoot, ] string callbackEventName) bool serverLog(int level, string message, [ int red = 255, int green = 255, int blue = 255 ]) bool serverNotice(string message, [ int red = 255, int green = 255, int blue = 255 ]), serverWarn(…) and serverError(…) On-screen debugging: int getOnScreenLogCount([ string column = nil ]) int initOnScreenLog([ element sourceResource = nil, ] string message, [ int pauseUpdate = 0, mixed textAlign = "center", int red = 255, int green = 255, int blue = 255, int alpha = 255 ]) void clearOnScreenLog(int logID) bool updateOnScreenLog(int logID, table data, [ string calcMode = nil ]) bool simpleOnScreenLog(string message, table data, [ mixed textAlign = "center", int red = 255, int green = 255, int blue = 255, int alpha = 255 ]) Last but not least it exports the following shared functions: void dump(mixed variable, [ string name = nil, int level = 3 ]) string get(mixed variable) When you're experiencing problems with PhrozenByte Debug, please don't hesitate to create a new Issue on GitHub. If you're a developer, you can help make PhrozenByte Debug better by contributing code; simply open a new PR on GitHub. Contributing to PhrozenByte Debug is highly appreciated! License PhrozenByte Debug is free software, released under the terms of the GNU Affero General Public License version 3 (GNU AGPL). This license offers you maximum freedom to modify the software and create derivatives to fit your needs. However, you must comply with some conditions regarding the disclosure of your modified source code. Please refer to our License tl;dr on GitHub for details. Edited September 14, 2016 by PhrozenByte Link to comment
Simple0x47 Posted September 14, 2016 Share Posted September 14, 2016 I just don't get why I should use this as debug method when I've got the outputChatBox as debug method Link to comment
PhrozenByte Posted September 14, 2016 Author Share Posted September 14, 2016 (edited) First of all: Naturally you don't have to use it, I do not intend to change anyones debugging preferences. The main goal of this resource is to allow both on-the-fly debugging on productive systems and keeping the server logs clean. Many resource developers use some global variable in LUA (e.g. DEBUG_MODE) to enable/disable their debug messages. The main disadvantage of this approach is that you can't enable debugging without restarting the resource (i.e. on-the-fly debugging). Depending on the resource and its ability to cleanup when being stopped, this might break its functionality or makes the issue you're trying to debug disappear. Using outputChatBox() furthermore shows the debug message to all players - something you definitely don't want to when debugging an issue that encounters only on productive systems. That's the reason why MTA supports the outputDebugString() function. However, this function doesn't really check whether a user is actually debugging and floods your server log all the time (i.e. keeping the logs clean). The resource furthermore allows you to send client-side debug strings to the server (serverLog() functions) and provides some very helpful debugging functions (dump() and get() - which I forgot to mention... I'll edit the post appropriately). Another big feature of this resource is on-screen-logging. It's quite impossible to debug a resource which uses the onClientRender() event. This resource adds a great technique to debug such features and even allows you to calculate means (e.g. to update a value just once a second so you can actually read it). The above screenshot shows on-screen-debugging in action, it shows the debug gravity information of the magnet marker of PhrozenByte Stunt Drag Markers at the top of the screen. And not to forget: It's open source. Edited September 14, 2016 by PhrozenByte Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now