#define log_error(Str, …) \
event_logger(LOG_ERROR, NULL, \
__FILE__, __PRETTY_FUNCTION__, __LINE__, \
NULL, NULL, \
GOD, (Str), ## __VA_ARGS__ )
"INFO",
"ERROR",
"FATAL",
"BOOT",
"AUTH",
"KILL",
"GAIN",
"RESET"
void event_logger( unsigned int Type, const char *BugFile,
const char *File, const char *Func, int Line,
struct char_data *ch, struct char_data *victim,
int Level, const char *Str, … )
__attribute__ ( ( format( printf, 9, 10 ) ) );
#define log_auth(Ch, Str, …) \
event_logger(LOG_AUTH, NULL, \
NULL, NULL, 0, \
(Ch), NULL, \
GOD, (Str), ## __VA_ARGS__ )
void proper_exit( int code, const char *Str, … )decides to log an error…. it has two choices.
__attribute__ ( ( format( printf, 2, 3 ) ) );;
void va_event_logger( unsigned int Type, const char *BugFile,
const char *File, const char *Func, int Line,
struct char_data *ch, struct char_data *victim,
int Level, const char *Str, va_list varg );
bug.c: In function 'void va_event_logger(unsigned int, const char*, const char*, const char*, int, char_data*, char_data*, int, const char*, char*)':
bug.c:143: warning: function might be possible candidate for 'printf' format attribute
quixadhal@andropov:~/svn/ram-project/area$ ../src/rom 4000
<: 2008-10-23 19:59:43.613 - ERROR - : Fix_exits: 10525:1 -> 10535:3 -> 10534.
<: 2008-10-23 19:59:43.614 - ERROR - : Fix_exits: 3458:2 -> 3472:0 -> 10401.
<: 2008-10-23 19:59:43.615 - ERROR - : Fix_exits: 8705:4 -> 8706:5 -> 8708.
<: 2008-10-23 19:59:43.615 - ERROR - : Fix_exits: 8717:2 -> 8719:0 -> 8718.
<: 2008-10-23 19:59:43.617 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.618 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.618 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.619 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.619 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.619 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.619 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.619 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.620 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.620 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.620 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.620 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.620 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.622 - ERROR - (db.c;reset_area,1449)
: Err: obj an icicle (9227) – 28, mob the Ice Bandit (9228) – 24
<: 2008-10-23 19:59:43.622 - ERROR - (db.c;reset_area,1449)
: Err: obj elemental wand of wind and air (9218) – 27, mob an alchemist (9234) – 13
<: 2008-10-23 19:59:43.623 - ERROR - (db.c;reset_area,1449)
: Err: obj an ice staff (9216) – 25, mob a baby rainbow dragon (9235) – 16
<: 2008-10-23 19:59:43.623 - ERROR - (db.c;reset_area,1449)
: Err: obj an ice staff (9216) – 25, mob a puddle (9214) – 8
<: 2008-10-23 19:59:43.623 - ERROR - (db.c;reset_area,1449)
: Err: obj elemental wand of fire (9215) – 16, mob a flame (9215) – 4
<: 2008-10-23 19:59:43.623 - ERROR - (db.c;reset_area,1449)
: Err: obj elemental wand of fire (9215) – 16, mob a flame (9215) – 4
<: 2008-10-23 19:59:43.624 - ERROR - (db.c;reset_area,1449)
: Err: obj an elemental rod of earthquake (9217) – 7, mob a small rock (9217) – 3
<: 2008-10-23 19:59:43.624 - ERROR - (db.c;reset_area,1449)
: Err: obj elemental wand of wind and air (9218) – 27, mob a small spark (9218) – 4
<: 2008-10-23 19:59:43.624 - ERROR - (db.c;reset_area,1449)
: Err: obj elemental wand of wind and air (9218) – 27, mob an eddie (9225) – 2
<: 2008-10-23 19:59:43.630 - ERROR - (db.c;reset_area,1449)
: Err: obj a wet noodle (8010) – 5, mob a Futsie (8002) – 17
<: 2008-10-23 19:59:43.632 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.634 - ERROR - : Read_object: vnum 3200 bad type.
<: 2008-10-23 19:59:43.638 - INFO - : ROM is ready to rock on port 4000.
<: 2008-10-23 19:59:47.135 - FATAL - (comm.c;proper_exit,2159)
: Game_loop: select: stall: Interrupted system call
<: 2008-10-23 19:59:43.630 - ERROR - (db.c;reset_area,1449)
: Err: obj a wet noodle (8010) – 5, mob a Futsie (8002) – 17
<: 2008-10-23 19:59:43.630 - ERROR - (db.c;reset_area,1449)
: Err: mob/obj level mismatch: obj a wet noodle (8010) – 5, mob a Futsie (8002) – 17
The version I modified for RaM uses 4-digit dates. :)
They are sequential, although those are two chunks from two different logs. I wanted to show the shutdown sequence as an example, and also some standard loading/reset messages.
The "type" tag is a field that can be grepped for if you want to look at a particular kind of event. I have macros for each of them, so entries like log_boot() show the source code file/function/line, whereas log_auth() or log_kill() show the character/victim/etc.
Putting dashes is easy enough. Back in 1995, I was using a vt220 terminal (I still have one… the vertical output transistor died in the last lightning storm we had though… they make great server console monitors). Thus, saving space was more important. How about "2008-10-23 14:20:03.011"?
It probably wouldn't be too hard to make them toggleable, certainly not by defines in the code, and probably not too hard as commands in game. Right now, the option of passing in a log filename is already in place, so you could redirect different types of events to different files. NOTE: If you are on a unix-like system, you can choose "/dev/null" as your filename, which will disable logging to a file (well, /dev/null will eat it), but still allow messages to online immortals.
All in all, my years of programming have taught me that a "bug" logger is useful, but an "event" logger is more reliable. Quite often, you don't see any cause for an error in the bug log, because the actual cause was something NOT happening that should have. For example, knowing that assigning a special-proc to mob 723611 failed is much more useful if you notice that foo.area didn't show up in the boot log, NOR did it show up as a failure during boot. That means one of your bozo underlings screwed up the area.list file again. :)