Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging infrastructure update #256

Merged
merged 11 commits into from
Mar 10, 2024
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"cinttypes": "cpp",
"codecvt": "cpp",
"charconv": "cpp",
"source_location": "cpp"
"source_location": "cpp",
"cerrno": "cpp"
},
"testMate.cpp.test.executables": "tests/*{_tests}*",
"testMate.cpp.debug.configTemplate": {
Expand Down
22 changes: 11 additions & 11 deletions code/act_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
#include "characterClasses/thief.h"
#include "chardef.h"
#include "update.h"
#include "./include/fmt/format.h"
#include "./include/fmt/printf.h"
#include "./include/spdlog/fmt/bundled/format.h"
#include "./include/spdlog/fmt/bundled/printf.h"

/* RT code to delete yourself */
void do_delet(CHAR_DATA *ch, char *argument)
Expand Down Expand Up @@ -1775,7 +1775,7 @@ void do_quit_new(CHAR_DATA *ch, char *argument, bool autoq)
if (CQueue::HasQueuePending(ch))
{
if (autoq)
RS.Bug("Trying to autoquit char %s with pending queue.", ch->name);
RS.Logger.Warn("Trying to autoquit char {} with pending queue.", ch->name);

send_to_char("You cannot quit while events requiring your presence are pending.\n\r", ch);
return;
Expand All @@ -1793,16 +1793,16 @@ void do_quit_new(CHAR_DATA *ch, char *argument, bool autoq)
send_to_char("Alas, all good things must come to an end.\n\r", ch);
act("$n has left the realm.", ch, nullptr, nullptr, TO_ROOM);

sprintf(log_buf, "%s@%s has %squit. [%ld played, %d (%d) obj]",
auto buffer = fmt::format("{}@{} has {}quit. [{} played, {} ({}) obj]",
ch->true_name,
!IS_SET(ch->comm, COMM_NOSOCKET) ? ch->pcdata->host : "",
autoq ? "auto" : "",
((current_time - ch->logon) / 60),
count_carried(ch, false),
count_carried(ch, true));

RS.Log(log_buf);
wiznet(log_buf, ch, nullptr, WIZ_SITES, 0, get_trust(ch));
RS.Logger.Info(buffer);
wiznet(buffer.data(), ch, nullptr, WIZ_SITES, 0, get_trust(ch));
login_log(ch, 2);

/*
Expand Down Expand Up @@ -1967,7 +1967,7 @@ void add_follower(CHAR_DATA *ch, CHAR_DATA *master)
{
if (ch->master != nullptr)
{
RS.Bug("Add_follower: non-nullptr master.");
RS.Logger.Debug("Add_follower: non-nullptr master.");
return;
}

Expand Down Expand Up @@ -2011,7 +2011,7 @@ void stop_follower(CHAR_DATA *ch)
{
if (ch->master == nullptr)
{
RS.Bug("Stop_follower: nullptr master.");
RS.Logger.Debug("Stop_follower: nullptr master.");
return;
}

Expand Down Expand Up @@ -2057,7 +2057,7 @@ void die_follower(CHAR_DATA *ch)
{
if (!ch)
{
RS.Bug("Error: Die follower, invalid master.");
RS.Logger.Debug("Error: Die follower, invalid master.");
return;
}

Expand All @@ -2077,7 +2077,7 @@ void die_follower(CHAR_DATA *ch)
fch_next = fch->next;
/*if(!fch->in_room && is_npc(fch))
{
RS.Bug("Error: Mob %d in room is nullptr!",fch->pIndexData->vnum);
RS.Logger.Debug("Error: Mob {} in room is nullptr!",fch->pIndexData->vnum);
break;
}*/
if (is_npc(fch) && (is_affected(fch, gsn_animate_dead) || is_affected_by(fch, AFF_CHARM)))
Expand Down Expand Up @@ -2574,7 +2574,7 @@ void speech_handler(CHAR_DATA *ch, CHAR_DATA *mob, SPEECH_DATA *speech)
do_sing(mob, buf);
break;
default:
RS.Bug("Error in speech -- missing/invalid type.");
RS.Logger.Warn("Error in speech -- missing/invalid type.");
return;
}

Expand Down
8 changes: 4 additions & 4 deletions code/act_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
#include "utility.h"
#include "skills.h"
#include "save.h"
#include "./include/fmt/format.h"
#include "./include/fmt/printf.h"
#include "./include/spdlog/fmt/bundled/format.h"
#include "./include/spdlog/fmt/bundled/printf.h"

char *const where_name[] = {
"<used as light> ",
Expand Down Expand Up @@ -3850,7 +3850,7 @@ void set_title(CHAR_DATA *ch, char *title)
{
if (is_npc(ch))
{
RS.Bug("Set_title: NPC.");
RS.Logger.Debug("Set_title: NPC.");
return;
}

Expand Down Expand Up @@ -3956,7 +3956,7 @@ void set_extitle(CHAR_DATA *ch, char *title)
{
if (is_npc(ch))
{
RS.Bug("Set_extitle: NPC.");
RS.Logger.Debug("Set_extitle: NPC.");
return;
}

Expand Down
16 changes: 7 additions & 9 deletions code/act_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void move_char(CHAR_DATA *ch, int door, bool automatic, bool fcharm)

if (door < 0 || door > 5)
{
RS.Bug("Do_move: bad door %d.", door);
RS.Logger.Warn("Do_move: bad door {}.", door);
return;
}

Expand Down Expand Up @@ -3653,7 +3653,7 @@ void do_animal_call(CHAR_DATA *ch, char *argument)
auto pMobIndex = get_mob_index(type);
if (pMobIndex == nullptr)
{
RS.Bug("Animal call: Bad mob vnum call %d.", type);
RS.Logger.Warn("Animal call: Bad mob vnum call {}.", type);

send_to_char("You call out to the wild but nothing responds.\n\r", ch);
act("$n calls out to the wild but nothing responds.", ch, 0, 0, TO_ROOM);
Expand Down Expand Up @@ -3718,7 +3718,7 @@ void do_animal_call(CHAR_DATA *ch, char *argument)
}
else
{
RS.Bug("Bad animal call: %d.", type);
RS.Logger.Warn("Bad animal call: {}.", type);

send_to_char("You call out to the wild but nothing responds.\n\r", ch);
act("$n calls out to the wild but nothing comes.\n\r", ch, 0, 0, TO_ROOM);
Expand Down Expand Up @@ -3846,7 +3846,7 @@ void smart_track(CHAR_DATA *ch, CHAR_DATA *mob)
sprintf(buf,"MOB %s tracking from ROOM %d to ROOM %d -- %d iterations.\n\r",
mob->name, mob->in_room->vnum,
ch->in_room->vnum,iterations);
RS.Bug(buf);
RS.Logger.Warn(buf);
*/
return;
}
Expand All @@ -3861,12 +3861,11 @@ void smart_track(CHAR_DATA *ch, CHAR_DATA *mob)

/* Uncomment for tracking info */
/*
sprintf(buf,"MOB %s tracking from ROOM %d to ROOM %d -- %d iterations.\n\r",
RS.Logger.Info("MOB {} tracking from ROOM {} to ROOM {} -- {} iterations.\n\r",
mob->name,
mob->in_room->vnum,
ch->in_room->vnum,
iterations);
RS.Log(buf);
*/

move_char(mob, solve->dir_from, false, true);
Expand Down Expand Up @@ -3915,7 +3914,7 @@ void walk_to_room(CHAR_DATA *mob, ROOM_INDEX_DATA *goal)
auto solve = best_path;
if (!best_path)
{
RS.Bug("Some weird tracking shit just happened with mob vnum %d.", mob->pIndexData->vnum);
RS.Logger.Warn("Some weird tracking shit just happened with mob vnum {}.", mob->pIndexData->vnum);
return;
}

Expand All @@ -3928,12 +3927,11 @@ void walk_to_room(CHAR_DATA *mob, ROOM_INDEX_DATA *goal)
}

/*
sprintf(buf,"MOB %s walking from ROOM %d to ROOM %d -- %d iterations.\n\r",
RS.Logger.Info("MOB {} walking from ROOM {} to ROOM {} -- {} iterations.\n\r",
mob->name,
mob->in_room->vnum,
goal->vnum,
iterations);
RS.Log(buf);
*/

move_char(mob, solve->dir_from, false, true);
Expand Down
31 changes: 14 additions & 17 deletions code/act_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#include "characterClasses/warrior.h"
#include "misc.h"
#include "skills.h"
#include "./include/fmt/format.h"
#include "./include/spdlog/fmt/bundled/format.h"

#define MINOTAUR_ONLY ASCII_I

Expand Down Expand Up @@ -102,18 +102,15 @@ bool check_arms(CHAR_DATA *ch, OBJ_DATA *obj)
bool can_loot(CHAR_DATA *ch, OBJ_DATA *obj)
{
CHAR_DATA *owner, *wch;
char buf[MAX_STRING_LENGTH];

if (obj->item_type == ITEM_CORPSE_PC
&& (!is_npc(ch) || is_affected_by(ch, AFF_CHARM)))
{
sprintf(buf, "%s looting %s.",
RS.Logger.Info("{} looting {}.",
is_npc(ch)
? ((ch->master == nullptr) ? "Unknown mob" : ch->master->name)
: ch->name,
obj->short_descr);

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

Expand Down Expand Up @@ -1696,7 +1693,7 @@ void do_drink(CHAR_DATA *ch, char *argument)

if (liquid < 0)
{
RS.Bug("Do_drink: bad liquid number, %d, on %s.", liquid, obj->short_descr);
RS.Logger.Warn("Do_drink: bad liquid number, {}, on {}.", liquid, obj->short_descr);
liquid = obj->value[2] = 0;
}

Expand All @@ -1713,7 +1710,7 @@ void do_drink(CHAR_DATA *ch, char *argument)

if (liquid < 0)
{
RS.Bug("Do_drink: bad liquid number, %d, on %s.", liquid, obj->short_descr);
RS.Logger.Warn("Do_drink: bad liquid number, {}, on {}.", liquid, obj->short_descr);
liquid = obj->value[2] = 0;
}

Expand Down Expand Up @@ -2052,7 +2049,7 @@ void wear_obj(CHAR_DATA *ch, OBJ_DATA *obj, bool fReplace)
return;
}

RS.Bug("Wear_obj: no free neck.");
RS.Logger.Warn("Wear_obj: no free neck.");
send_to_char("You already wear two neck items.\n\r", ch);
return;
}
Expand Down Expand Up @@ -2185,7 +2182,7 @@ void wear_obj(CHAR_DATA *ch, OBJ_DATA *obj, bool fReplace)
return;
}

RS.Bug("Wear_obj: no free wrist.");
RS.Logger.Warn("Wear_obj: no free wrist.");
send_to_char("You already wear two wrist items.\n\r", ch);
return;
}
Expand Down Expand Up @@ -3088,7 +3085,7 @@ void do_brandish(CHAR_DATA *ch, char *argument)

if (sn < 0 || sn >= MAX_SKILL || skill_table[sn].spell_fun == 0)
{
RS.Bug("Do_brandish: bad sn %d.", sn);
RS.Logger.Warn("Do_brandish: bad sn {}.", sn);
return;
}

Expand Down Expand Up @@ -3142,7 +3139,7 @@ void do_brandish(CHAR_DATA *ch, char *argument)

break;
default:
RS.Bug("Do_brandish: bad target for sn %d.", sn);
RS.Logger.Warn("Do_brandish: bad target for sn {}.", sn);
return;
}

Expand Down Expand Up @@ -3685,7 +3682,7 @@ void do_buy(CHAR_DATA *ch, char *argument)
pRoomIndexNext = get_room_index(ch->in_room->vnum + 1);
if (pRoomIndexNext == nullptr)
{
RS.Bug("Do_buy: bad pet shop at vnum %d.", ch->in_room->vnum);
RS.Logger.Debug("Do_buy: bad pet shop at vnum {}.", ch->in_room->vnum);
send_to_char("Sorry, you can't buy that here.\n\r", ch);
return;
}
Expand Down Expand Up @@ -3967,7 +3964,7 @@ void do_list(CHAR_DATA *ch, char *argument)

if (pRoomIndexNext == nullptr)
{
RS.Bug("Do_list: bad pet shop at vnum %d.", ch->in_room->vnum);
RS.Logger.Debug("Do_list: bad pet shop at vnum {}", ch->in_room->vnum);
send_to_char("You can't do that here.\n\r", ch);
return;
}
Expand Down Expand Up @@ -4407,7 +4404,7 @@ bool hands_full(CHAR_DATA *ch)
return false;

if (count > 2)
RS.Bug("Hands full: Character holding %d items.", count);
RS.Logger.Warn("Hands full: Character holding {} items.", count);

return true;
}
Expand Down Expand Up @@ -4816,7 +4813,7 @@ void report_weapon_skill(CHAR_DATA *ch, OBJ_DATA *obj)

if (obj->item_type != ITEM_WEAPON)
{
RS.Bug("report_weapon_skill: Bad obj->type, %d, vnum %d, carried by %s.",
RS.Logger.Debug("report_weapon_skill: Bad obj->type, {}, vnum {}, carried by {}.",
obj->item_type,
obj->pIndexData->vnum,
ch->name);
Expand Down Expand Up @@ -4906,7 +4903,7 @@ void save_cabal_items(void)

if (fp == nullptr)
{
perror(CABAL_ITEMS_FILE);
RS.Logger.Warn("Save_cabal_items: fopen {}: {}", CABAL_ITEMS_FILE, std::strerror(errno));
return;
}

Expand Down
10 changes: 5 additions & 5 deletions code/act_wiz.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
#include "material.h"
#include "utility.h"
#include "misc.h"
#include "./include/fmt/format.h"
#include "./include/fmt/printf.h"
#include "./include/spdlog/fmt/bundled/format.h"
#include "./include/spdlog/fmt/bundled/printf.h"

AREA_DATA *area_first;
unsigned int *gDebug;
Expand Down Expand Up @@ -1079,7 +1079,7 @@ void do_disconnect(CHAR_DATA *ch, char *argument)
}
}

RS.Bug("Do_disconnect: desc not found.");
RS.Logger.Warn("Do_disconnect: desc not found.");
send_to_char("Descriptor not found!\n\r", ch);
}

Expand Down Expand Up @@ -2200,7 +2200,7 @@ void do_ostat(CHAR_DATA *ch, char *argument)

if (!ispec_table[i].spec_name)
{
RS.Bug("Error: Invalid ispec.");
RS.Logger.Warn("Error: Invalid ispec.");
return;
}

Expand Down Expand Up @@ -2838,7 +2838,7 @@ void do_mstat(CHAR_DATA *ch, char *argument)

if (!mspec_table[i].spec_name)
{
RS.Bug("Error: Invalid mspec.");
RS.Logger.Warn("Error: Invalid mspec.");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion code/alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "interp.h"
#include "db.h"
#include "utility.h"
#include "./include/fmt/format.h"
#include "./include/spdlog/fmt/bundled/format.h"

/* does aliasing and other fun stuff */
void substitute_alias(DESCRIPTOR_DATA *d, char *argument)
Expand Down
2 changes: 1 addition & 1 deletion code/aprog.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void aprog_set(AREA_DATA *area, const char *progtype, const char *name)

if (!aprog_table[i].name)
{
RS.Bug("Load_improgs: 'A': Function not found for area %s.", area->name);
RS.Logger.Warn("Load_improgs: 'A': Function not found for area {}.", area->name);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion code/ban.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "act_wiz.h"
#include "interp.h"
#include "db.h"
#include "./include/fmt/format.h"
#include "./include/spdlog/fmt/bundled/format.h"

/// Determines if a player has been banned.
/// @param usite: The IP address or DNS name of the computer that the player uses to connect.
Expand Down
Loading
Loading