Skip to content

Commit

Permalink
Consolidate logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-gilliam committed Oct 25, 2023
1 parent 07f4aa1 commit 4f25abc
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 46 deletions.
2 changes: 1 addition & 1 deletion code/act_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ void do_quit_new(CHAR_DATA *ch, char *argument, bool autoq)
count_carried(ch, false),
count_carried(ch, true));

log_string(log_buf);
RS.Log(log_buf);
wiznet(log_buf, ch, nullptr, WIZ_SITES, 0, get_trust(ch));
login_log(ch, 2);

Expand Down
4 changes: 2 additions & 2 deletions code/act_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -3866,7 +3866,7 @@ void smart_track(CHAR_DATA *ch, CHAR_DATA *mob)
mob->in_room->vnum,
ch->in_room->vnum,
iterations);
log_string(buf);
RS.Log(buf);
*/

move_char(mob, solve->dir_from, false, true);
Expand Down Expand Up @@ -3933,7 +3933,7 @@ void walk_to_room(CHAR_DATA *mob, ROOM_INDEX_DATA *goal)
mob->in_room->vnum,
goal->vnum,
iterations);
log_string(buf);
RS.Log(buf);
*/

move_char(mob, solve->dir_from, false, true);
Expand Down
2 changes: 1 addition & 1 deletion code/act_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bool can_loot(CHAR_DATA *ch, OBJ_DATA *obj)
: ch->name,
obj->short_descr);

log_string(buf);
RS.Log(buf);
ch->pause = 5;
}

Expand Down
8 changes: 4 additions & 4 deletions code/bootup.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void CMud::LoadObjLimits()
{
strcpy(strPlr, fread_word(fpChar_list) );
if(bDebug)
log_string(strPlr);
RS.Log(strPlr);

if (!str_cmp(strPlr,chkbuf))
break;
Expand Down Expand Up @@ -114,7 +114,7 @@ void CMud::LoadObjLimits()
if(lastlogin && plevel && plevel < 52 && lastlogin + 3456000 < current_time)
{
auto buffer = fmt::format("Autodeleting {}.", temp_player_name);
log_string(buffer.c_str());
RS.Log(buffer.c_str());
breakout = true;
delete_char(temp_player_name, true);
break;
Expand Down Expand Up @@ -205,7 +205,7 @@ void CMud::LoadAreas()
{
FILE *fpList;

log_string("Loading area files now...");
RS.Log("Loading area files now...");

if ( ( fpList = fopen( AREA_LIST, "r" ) ) == nullptr )
{
Expand All @@ -221,7 +221,7 @@ void CMud::LoadAreas()
break;

if (bDebug)
log_string(strArea);
RS.Log(strArea);

if ( strArea[0] == '-' )
{
Expand Down
18 changes: 9 additions & 9 deletions code/comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,11 @@ void init_descriptor(int control)

sprintf(buf, "%d.%d.%d.%d", (addr >> 24) & 0xFF, (addr >> 16) & 0xFF, (addr >> 8) & 0xFF, (addr)&0xFF);
sprintf(log_buf, "Sock.sinaddr: %s", buf);
log_string(log_buf);
RS.Log(log_buf);

if (strstr(buf, "204.82.56."))
{
log_string("DNS lookup refused. Forbidding access.");
RS.Log("DNS lookup refused. Forbidding access.");
write_to_descriptor(desc, "Your site has been banned from this mud due to DNS problems.\n\r", 0);

close(desc);
Expand Down Expand Up @@ -580,7 +580,7 @@ void close_socket(DESCRIPTOR_DATA *dclose)
if ((ch = dclose->character) != nullptr)
{
sprintf(log_buf, "Closing link to %s.", ch->name);
log_string(log_buf);
RS.Log(log_buf);

/* cut down on wiznet spam when rebooting */
if (dclose->connected == CON_PLAYING && !merc_down)
Expand Down Expand Up @@ -640,7 +640,7 @@ bool read_from_descriptor(DESCRIPTOR_DATA *d)
if (iStart >= sizeof(d->inbuf) - 10)
{
sprintf(log_buf, "%s input overflow!", d->host);
log_string(log_buf);
RS.Log(log_buf);

write_to_descriptor(d->descriptor, "\n\r*** PUT A LID ON IT!!! ***\n\r", 0);
return false;
Expand All @@ -659,7 +659,7 @@ bool read_from_descriptor(DESCRIPTOR_DATA *d)
}
else if (nRead == 0)
{
log_string("EOF encountered on read.");
RS.Log("EOF encountered on read.");
return false;
}
else if (errno == EAGAIN)
Expand Down Expand Up @@ -1498,7 +1498,7 @@ void nanny(DESCRIPTOR_DATA *d, char *argument)
if (IS_SET(ch->act, PLR_DENY))
{
sprintf(log_buf, "Denying access to %s@%s.", argument, d->host);
log_string(log_buf);
RS.Log(log_buf);

write_to_buffer(d, "You are denied access.\n\r", 0);
close_socket(d);
Expand Down Expand Up @@ -1621,7 +1621,7 @@ void nanny(DESCRIPTOR_DATA *d, char *argument)
count_carried(ch, true),
auto_check_multi(d, d->host) ? " (MULTI)" : "");

log_string(log_buf);
RS.Log(log_buf);
login_log(ch, 1);

wiznet(log_buf, nullptr, nullptr, WIZ_SITES, 0, get_trust(ch));
Expand Down Expand Up @@ -2022,7 +2022,7 @@ void nanny(DESCRIPTOR_DATA *d, char *argument)
sprintf(log_buf, "%s@%s new player.%s",
ch->name, d->host,
auto_check_multi(d, d->host) ? " (MULTI-CHAR?)" : "");
log_string(log_buf);
RS.Log(log_buf);
login_log(ch, 0);

wiznet("Newbie alert! $N sighted.", ch, nullptr, WIZ_NEWBIE, 0, 0);
Expand Down Expand Up @@ -2965,7 +2965,7 @@ bool check_reconnect(DESCRIPTOR_DATA *d, char *name, bool fConn)
}

sprintf(log_buf, "%s@%s reconnected.", ch->name, d->host);
log_string(log_buf);
RS.Log(log_buf);

wiznet("$N recovers from link death.", ch, nullptr, WIZ_LINKS, 0, get_trust(ch));
d->connected = CON_PLAYING;
Expand Down
18 changes: 3 additions & 15 deletions code/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -3773,27 +3773,15 @@ void bug(const char *str, int param)
}

buffer = fmt::format("[*****] FILE: {} LINE: {}", strArea, iLine);
log_string(buffer.c_str());
RS.Log(buffer.c_str());
}

buffer = fmt::sprintf(str, param);
buffer = fmt::format("[*****] BUG: {}", buffer);
log_string(buffer.c_str());
RS.Log(buffer.c_str());
wiznet(buffer.data(), 0, 0, WIZ_DEBUG, 0, 0);
}

/*
* Writes a string to the log.
*/
void log_string(const char *str)
{
char *strtime;

strtime = ctime(&current_time);
strtime[strlen(strtime) - 1] = '\0';
fprintf(stderr, "%s :: %s\n", strtime, str);
}

/*
* This function is here to aid in debugging.
* If the last expression in a function is another function call,
Expand Down Expand Up @@ -3974,7 +3962,7 @@ void do_llimit(CHAR_DATA *ch, char *argument)
for (;;)
{
strcpy(strPlr, fread_word(fpChar_list));
// log_string(strPlr);
// RS.Log(strPlr);
sprintf(chkbuf, "%s/%s", RIFT_PLAYER_DIR, "Zzz.plr");

if (!str_cmp(strPlr, chkbuf))
Expand Down
1 change: 0 additions & 1 deletion code/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ void append_file (CHAR_DATA *ch, char *file, char *str);
* Reports a bug.
*/
void bug(const char *str, int param);
void log_string (const char *str);
void tail_chain(void);
void do_force_reset(CHAR_DATA *ch, char *argument);
/*
Expand Down
2 changes: 1 addition & 1 deletion code/devextra.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void clean_mud()
if (!load_char_obj(d, tbuf))
{
nSQL.Delete("players WHERE name = '%s'", row[0]);
log_string("Deleting player...");
RS.Log("Deleting player...");
}

free_char(d->character);
Expand Down
8 changes: 4 additions & 4 deletions code/fight.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ int damage_new(CHAR_DATA *ch, CHAR_DATA *victim, int idam, int dt, int dam_type,
victim->name,
(is_npc(ch) ? ch->short_descr : ch->name),
ch->in_room->vnum);
log_string(log_buf);
RS.Log(log_buf);
}

/*
Expand Down Expand Up @@ -3582,21 +3582,21 @@ void pk_record(CHAR_DATA *ch, CHAR_DATA *victim)
if (is_same_group(wch, ch) && !is_npc(wch) && (wch->in_room == ch->in_room || wch->ghost > 0))
{
sprintf(buf, "Adding %s to killer_group", wch->name);
log_string(buf);
RS.Log(buf);
killer_group++;
}

if (is_same_group(wch, ch) && wch->in_room == ch->in_room && !is_npc(wch))
{
sprintf(buf, "Adding %s to killer_in_room", wch->name);
log_string(buf);
RS.Log(buf);
killer_in_room++;
}

if (is_same_group(wch, victim) && (wch->in_room == victim->in_room || wch->ghost > 0))
{
sprintf(buf, "Adding %s to victim_group.", wch->name);
log_string(buf);
RS.Log(buf);
victim_group++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ void interpret(CHAR_DATA *ch, char *argument)
{
sprintf(log_buf, "Log %s: %s", ch->desc->original ? ch->desc->original->true_name : ch->true_name, logline);
wiznet(log_buf, ch, nullptr, WIZ_SECURE, 0, get_trust(ch));
log_string(log_buf);
RS.Log(log_buf);
}

if (ch->desc != nullptr && ch->desc->snoop_by != nullptr)
Expand Down
6 changes: 3 additions & 3 deletions code/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ int main(int argc, char **argv)
// boot_db( );
if (!RS.Bootup())
{
log_string("Riftshadow failed to boot, aborting.");
RS.Log("Riftshadow failed to boot, aborting.");
exit(0);
return 0;
}

sprintf(buf, "Riftshadow booted, binding on port %d.", port);
log_string(buf);
RS.Log(buf);

game_loop_unix(control);
close(control);

/*
* That's all, folks.
*/
log_string("Normal termination of game.");
RS.Log("Normal termination of game.");
exit(0);
return 0;
}
2 changes: 1 addition & 1 deletion code/olc_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ void do_asave(CHAR_DATA *ch, char *argument)
continue;

clean_olc_aflags(pArea);
log_string(pArea->name);
RS.Log(pArea->name);

sprintf(buf, "Saving..%s\n", pArea->name);
wiznet(buf, 0, nullptr, WIZ_DEBUG, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion code/save.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ void fread_char(CHAR_DATA *ch, FILE *fp)
TROPHY_DATA *placeholder;

sprintf(buf, "Loading %s.", ch->name);
log_string(buf);
RS.Log(buf);

zero_vector(limmune_flags);
zero_vector(lres_flags);
Expand Down
4 changes: 2 additions & 2 deletions code/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void gain_exp(CHAR_DATA *ch, int gain)
ch->level += 1;

sprintf(buf, "%s gained level %d", ch->name, ch->level);
log_string(buf);
RS.Log(buf);

sprintf(buf, "$N has attained level %d!", ch->level);
wiznet(buf, ch, nullptr, WIZ_LEVELS, 0, 0);
Expand Down Expand Up @@ -2300,7 +2300,7 @@ void affect_update(void)
wiznet("ERROR: $N had corrupt name! Name has been properly repaired. Check for other errors.", ch, nullptr, 0, 0, 0);
sprintf(buf, "Error: %s has corrupt name. Repaired.\n\r", ch->true_name);
bug(buf, 0);
log_string(buf);
RS.Log(buf);
}

for (paf = ch->affected; paf; paf = paf_next)
Expand Down

0 comments on commit 4f25abc

Please sign in to comment.