Quote:
Originally Posted by kvann
If you are planning to create a log viewing interface for your admins on your website or somewhere else, a database is 100% the way to go. I recently built a general purpose logging service in golang (and a client for SA-MP), I'm not going to get into the details since it's an overkill for SA-MP with its queue system needed for checksum chaining, but leaving that out, something similar is fairly easy to implement in PAWN. It might be tempting to just create a table for each log with the necessary parameters (I also fell into that trap years ago), but it makes the process of creating a viewing interface much more complex and time-consuming. Instead of that, my logger is using a fully normalised database model that stores the log types in one table, the parameters associated with them in another, the log rows in another and the parameters associated with them in another. Here is my database model:
It's far from perfect, for example all values are stored as strings (with a limited length, 256 should be enough from everything sent from SA-MP though) and the parameters are missing foreign keys to non-log-related tables, even though they could be useful in some cases. It is a lot better than hardcoding the tables and their columns, though.
MySQL is easily capable of handling large amounts of data, take a look at the companies using it, they are far more demanding than a single SA-MP server. It will also not cause any performance issues with the SA-MP server itself, once the query is dispatched, the server will not expect any response from the database.
|
Wouh, I wasn't expecting such serious answer! Thanks for your response, and let me explain you why I do not like your table and column management. I wanted to do something like player chat displaying on my ucp panel or online chat tracking via website for admins FOR CERTAIN PLAYER. If player gets message (chat message, not pm, admin chat or any other message) - that message is stored in database. If he sends that message - it also goes to database. In this proper way I want create an opportunity for admins to see the whole certain player chat. Why am I doing it this way? I don't see any sense of storing just sender name/id and message what he send. If I will have 1000players in future, they all are playing over whole San Andreas map, and how should I detect to whom of left 999players this specified message is adressed? Totally nonsens. Thats how my database management system is made. First of all I have done two mysql connections using mysql_global_options(DUPLICATE_CONNECTIONS, true);. One will be my main database with users, houses, vehicles, etc, and second one is provided entirely for logging purposes. I have separate tables for chat logs, commands, server logs, sms logs, and connections (connects and disconnects). For now, I have only done server log part yet, cause I don't even have registration/login systems in my gamemode, its entirely blank IG, but for now I'm just preparing it for future easier work with it. Soo, I have 3 columns, as far as I remember (I'm writing this post from the phone, soo there is no way at this moment to check my database), ID (Auto increment, unique), Date (YYYY-MM-DD HH:MM:SS), and message itself. I have done Log function, with 3 parameters, 1 of them is optional. It looks like this: Log(type, text[], bool:error = false). Where type is, i put there one of my defines, for ex. LOG_TYPE_CHAT. In text I write comment for the log, actual log, if I can name it this way and error boolean is for kind of tag in text itself. If it's false - log output will start with this symbols [SUCCESS]. If error bool is true, the [SUCCESS] will change to [ERROR]. I'm planning to finish logs system in near future, and the hardest thing so far was generating the idea for proper chatlog saving, what would fit my requirements presented earlier. I decided to do it this way (If someone have better idea, you are free to share it), I have 6 columns. ID, SenderID, ReceiverID, Date, IP and Message. ID is auto increment and unique for every log. SenderID is the database unique ID of player, who sent this message. ReceiverID is player who got that message from Sender. I think there are no inneed of explaining other columns aswell
. For ex. if I would wrote something in chat, and near me would be staying a guy, he would receive that message. I'm sender, he is receiver. It may look quite easy from viewpoint of advanced scripter, but I'm scripting only for 9months approximately with breaks of total around 6 months, so I think this solution is quite good for beginner. That's how I decided to store my logs, for easier implementation of live IG chat system or simple chat logs reviewing for admins. What about logging system what you made, I will check it tomorrow and maybe add some comments, if I like it. That's all what I wanted tell you about. Waiting for your response!