Jr Dev Code - Error logging
i mentioned a need for error logging centralization in the bugs forum. well i got my laptop back and slapped together the following. it sets up the infrastructure for the above as well as an extendable "utility function" set. By using this, this allows you to quickly and easily change often performed tasks(logging, etc)
lets see if i can get this code in here before my session times out. First I am going to paste two files needed to use this, util.h and util.c util.h Code:
// Code:
//util.c Ok there it is. Its semi readable. I'm a bit rusty in c/c++ but this compiles in vc++.net . please let me know if you have problems with it and i will try to polish it. Tto use the only (at the moment ) function in this file simply call it as follows: info_report( severity , "Error string"); severity is defined as a number between 0 and 4. defined as constants as follows: SEV_NULL=0 - unused, makes the numbers make more sense SEV_INFO=1 - Information, nothing wrong, maybe a login SEV_WARN=2 - Warning, minor problem SEV_ERRO=3 - error, something broke but not critical SEV_FATL=4 - severe error, server must terminate/restart so for example, to log an error with the database and a character could not be loaded, but the server can continue, it would be used as follows info_report(SEV_ERRO, "Error Loading Character, <enter reason here>"); THis can be edited and/or extended if need be. i think my comments explain how, let me know if you need clairification. Well thats it i think. Thanks for your time Maaltan |
This looks alot like an enterprise level logging model.. You don't happen to work in an IT industry do you?
|
used to, mostly just a hobby coder though. but the coms bombed and now I just code for fun.
thats not quite enterprise level, but it does lay the infrastructure for it though. enterprise would probably involve fault tolerant databases and redundancy. which would be possibly. using this as a starting point you could, say, recode info_report to insert logs into a mysql table. or a log file. This is nasty code. I would have probably been fired for this code, well not quite. :) |
Now you just need to create a stand alone logging daemon process and you have a robust logging solution !
|
Hmmm, thats do-able. Would you prefer to use named pipe, UDP, or Process hook? but I digress, its unnecessary for at this stage of development though.
It would be of benifit in the future if people start running high volume persistant clustered servers. do you know how to create patch files in visual c++? I will go through and replace all the errors with info_report calls and create a patch file that will allow you to quickly make the changes. i used to know how to do it in unix ..hmm . to GOOGLE. |
Now THIS is the kind of code we are looking for, or examples of things you have done with the emulator code. It needs to show skill, knowledge and competence.
|
total recall
ok i got bored so i learned how to use variable parameters. here is the updated util.cpp file
This update will let you use this exactly like printf. for example: Code:
opcode = 55; Code:
Warn [20:33:18] Unknown opcode: 55 Code:
#include "stdafx.h" int info_report(int severity, char* error); to int info_report(int severity, char* error, ...); |
All times are GMT -4. The time now is 11:54 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.