Chronicle of major events, and livelog

Log game events, such as entering a new dungeon level, breaking
a conduct, or killing a unique monster, in a new "Major events"
chronicle. The entries record the turn when the event happened.
The log can be viewed with #chronicle -command, and the entries
also show up in the end-of-game dump, if that is available.

This feature is on by default, but can be disabled by
defining NO_CHRONICLE compile-time option.

This also contains "live logging", writing the events as they
happen into a single livelog-file. This is mostly useful for
public servers. The livelog is off by default, and must be
compiled in with LIVELOG, and then turned on in sysconf.

Mostly this a version of livelogging from the Hardfought server,
with some changes.
This commit is contained in:
Pasi Kallinen
2022-02-09 22:49:25 +02:00
parent cfcfc3429f
commit 1e90f89203
43 changed files with 624 additions and 53 deletions
+55
View File
@@ -2578,6 +2578,13 @@ parse_config_line(char *origbuf)
n = 10;
}
sysopt.tt_oname_maxrank = n;
} else if (src == set_in_sysconf && match_varname(buf, "LIVELOG", 7)) {
n = strtol(bufp,NULL,0);
if (n < 0 || n > 0xFFFF) {
raw_printf("Illegal value in LIVELOG (must be between 0 and 0xFFFF).");
return 0;
}
sysopt.livelog = n;
/* SYSCF PANICTRACE options */
} else if (in_sysconf && match_varname(buf, "PANICTRACE_LIBC", 15)) {
@@ -4658,4 +4665,52 @@ Death_quote(char *buf, int bufsz)
/* ---------- END TRIBUTE ----------- */
#if defined LIVELOG
#define LLOG_SEP '\t' /* livelog field separator */
/* Locks the live log file and writes 'buffer'
* IF the ll_type matches sysopt.livelog mask
* lltype is included in LL entry for post-process filtering also
*/
void
livelog_add(unsigned int ll_type, const char *str)
{
FILE* livelogfile;
if (!(ll_type & sysopt.livelog))
return;
if (lock_file(LIVELOGFILE, SCOREPREFIX, 10)) {
if (!(livelogfile = fopen_datafile(LIVELOGFILE, "a", SCOREPREFIX))) {
pline("Cannot open live log file!");
unlock_file(LIVELOGFILE);
return;
}
fprintf(livelogfile,
"lltype=%d%cname=%s%crole=%s%crace=%s%cgender=%s%c"
"align=%s%cturns=%ld%cstarttime=%ld%ccurtime=%ld%c"
"message=%s\n",
(ll_type & sysopt.livelog), LLOG_SEP,
g.plname, LLOG_SEP,
g.urole.filecode, LLOG_SEP,
g.urace.filecode, LLOG_SEP,
genders[flags.female].filecode, LLOG_SEP,
aligns[1-u.ualign.type].filecode, LLOG_SEP,
g.moves, LLOG_SEP,
(long)ubirthday, LLOG_SEP,
(long)time(NULL),
LLOG_SEP, str);
(void) fclose(livelogfile);
unlock_file(LIVELOGFILE);
}
}
#undef LLOG_SEP
#else
void
livelog_add(unsigned int ll_type UNUSED, const char *str UNUSED)
{
/* nothing here */
}
#endif /* !LIVELOG */
/*files.c*/