One of the things I've been trying to do with my new engine/game is improve on The vast majority of games use a system for capturing errors/information like the one found here. While it might not be XML based, the fact of the matter is that it usually goes to a file on the users computer. In order for the developer to get the information the user must find the file, upload it, etc. This usually never happens, even in beta testing.
There are ways to automate this a bit by having an application that automatically uploads the file to us but we still have an issue. Specifically what if the program crashes, they start it back up (thus overwriting the error log), and then send us the error log sans error. To fight this we need either to continue to append to the file, thus creating potentially a huge file that would take forever to parse not to mention upload, or we create a new file each time the program is run (good luck finding the one with the error).
So how can we deal with these issues in a manner that wont cause people to want to beat us with sticks? Well one that I've been toying with is using a database. A database can hold numerous entries, is easily searchable, and can be centralized on a server instead of on the individual user's machine. So lets take a look at how we might do this.
Setup The Database
I'm not talking about installing the database or get into a discussion of whether you should use MySQL, SQL Server, etc. So at this point I'm just going to assume that you've made your decision, installed it, and configured it correctly on your server. However we still need to setup the tables. For this example we're only going to use a simple example using MySQL and C#. Assume that we setup a database/table using the following SQL:
create database ErrorLog;
use ErrorLog;
create table Errors (ErrorID int auto_increment not null, message char(5000), ErrorType int, File char(1024), Line int, primary key(ErrorID));
As you can see, we should have at this point a simple table that has an ID number, a spot for a message, error type, the file that the error came from, and the line number.
Setup The Code
Now in order to insert the information we can use a function like this:
public static void Error(string message,int ErrorType,string File,int Line)
{
System.Data.Odbc.OdbcConnection Connection;
string ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=ServerName;" + //The server location should go here
"DATABASE=ErrorLog;" + //The database name, in this case ErrorLog
"UID=UserID;" + //Whatever you've setup as the user name for the database
"PASSWORD=Password;" + //Whatever you've setup as the password for the database
"OPTION=3";
Connection = new System.Data.Odbc.OdbcConnection(ConnectionString);
Connection.Open();
System.Data.Odbc.OdbcCommand Command;
string CommandString = "insert into Errors(message,ErrorType,File,Line) values (" + message + "," + ErrorType + "," + File + "," + Line + ");";
Command = new System.Data.Odbc.OdbcCommand(CommandString, Connection);
int LinesInserted = Command.ExecuteNonQuery();
Connection.Close();
}
And voilà, we have a central database that contains all errors that occur, tells us where in the code they occur, etc. with the user not having to lift a finger.
Now there are some downsides to logging your events this way. First and foremost is that it is potentially rather slow. You have to wait for a message to be sent from the user to the database and back. So sending a couple of messages each loop will likely make your application crawl. Instead we could save the information onto the users machine in an XML file and only send the data when the application is closing. Or potentially we could only use this method during development and testing of the application and remove it for a more traditional system when it hits production.
Another issue is the fact that the person has to be connected to the Internet in order for this to work. However for games that are either strictly multiplayer (World of Warcraft, Shadowrun, etc.) or use a system like Steam might not be hindered by this aspect.
Lastly we have to worry about privacy issues. Any time we send information from the user's machine, we have to tell them and let them have the ability to opt out if they wish. If we do not, we risk angering quite a few people. So basically make sure they know about it, can opt out, make it anonymous, etc. and you shouldn't have many issues here.
So while this might not be the perfect solution for every game, it definitely is something to consider for some. The key is to experiment and find what works for you and your situation.
97dd39a6-4fd2-4e50-b9ca-c0ce1acc5e37|0|.0