08 Nov, 2009, Mudder wrote in the 1st comment:
Votes: 0
I was looking at the logging system that was added for RaM today and wanted to have it actually write to files. I thought it would be fairly easy but I must be missing something because I'm unable to get it working.

Merc.h said:
#define log_info(Str, …) \
event_logger(LOG_INFO, NULL, \
__FILE__, __FUNCTION__, __LINE__, \
NULL, NULL, \
GOD, (Str), ## __VA_ARGS__ )
#define log_error(Str, …) \
event_logger(LOG_ERROR, NULL, \
__FILE__, __FUNCTION__, __LINE__, \
NULL, NULL, \
GOD, (Str), ## __VA_ARGS__ )
#define log_fatal(Str, …) \
event_logger(LOG_FATAL, NULL, \
__FILE__, __FUNCTION__, __LINE__, \
NULL, NULL, \
GOD, (Str), ## __VA_ARGS__ )
#define log_boot(Str, …) \
event_logger(LOG_BOOT, NULL, \
__FILE__, __FUNCTION__, __LINE__, \
NULL, NULL, \
GOD, (Str), ## __VA_ARGS__ )
#define log_auth(Ch, Str, …) \
event_logger(LOG_AUTH, NULL, \
NULL, NULL, 0, \
(Ch), NULL, \
GOD, (Str), ## __VA_ARGS__ )
#define log_kill(Ch, Victim, Str, …) \
event_logger(LOG_KILL, NULL, \
NULL, NULL, 0, \
(Ch), (Victim), \
GOD, (Str), ## __VA_ARGS__ )

I had assumed simply replacing the green colored text with a file like BUG_FILE
#define BUG_FILE            SYS_DIR "/bugs.txt"        /* For 'bug' and bug() */

It would write to that file, but that is not so. What am I missing?
08 Nov, 2009, bbailey wrote in the 2nd comment:
Votes: 0
Mudder said:
I was looking at the logging system that was added for RaM today and wanted to have it actually write to files. I thought it would be fairly easy but I must be missing something because I'm unable to get it working.

Merc.h said:
#define log_info(Str, …) \
event_logger(LOG_INFO, NULL, \
__FILE__, __FUNCTION__, __LINE__, \
NULL, NULL, \
GOD, (Str), ## __VA_ARGS__ )

I had assumed simply replacing the green colored text with a file like BUG_FILE
#define BUG_FILE            SYS_DIR "/bugs.txt"        /* For 'bug' and bug() */

It would write to that file, but that is not so. What am I missing?


__FILE__, __FUNCTION__, and __LINE__ are variables (or macros) that are expanded either by the preprocessor (__FILE__ and __LINE__, usually) or compiler (__FUNCTION__, __PRETTY_FUNCTION__, and in C, __func__) at the time of compilation. Each instance will be replaced with the file name, function name, and line in the file, respectively, where that instance appears. They are useful primarily in debugging to display precisely where a logging or other debugging function was called.

I haven't looked at RaM's code so this is mostly guesswork, but I'd look at the actual event_logger() function to try and determine what changes are necessary to make it log to a file. The code referenced above is just preprocessor macro convenience wrappers for that function.
09 Nov, 2009, Mudder wrote in the 3rd comment:
Votes: 0
Whoops! A bit of an oversight on my part.

merc.h said:
#define log_info(Str, …) \
event_logger(LOG_INFO, NULL, \
__FILE__, __FUNCTION__, __LINE__, \
NULL, NULL, \
GOD, (Str), ## __VA_ARGS__ )


THIS is the one that is supposed to be replaced to write to a file. I did look at the event_logger and saw that it wrote to a file if provided, but I just (somehow) missed the first null next to LOG_INFO.

And thank you for the explanation about the __FILE, etc. Good to know what exactly was happening there. :biggrin:
09 Nov, 2009, David Haley wrote in the 4th comment:
Votes: 0
We'll have to see what event_logger is doing to know for sure. Or, a RaM expert could show up and say what the issue is. :smile:
09 Nov, 2009, Mudder wrote in the 5th comment:
Votes: 0
Oh, sorry if I misrepresented myself. My second statement is correct. The original confusion was because I did take a look at event_logger and I knew the second argument was what I wanted, but apparently I am blind and thought the __FILE__ was actually the second. I confirmed this with a nice, large, log file. :grinning:
10 Nov, 2009, David Haley wrote in the 6th comment:
Votes: 0
Oh, sorry. I thought you were saying that it still wasn't working. My bad! :redface:
0.0/6