diff options
| author | Spp <spp@jorge.gr> | 2012-08-03 14:20:18 +0200 | 
|---|---|---|
| committer | Spp <spp@jorge.gr> | 2012-08-03 14:20:18 +0200 | 
| commit | 55ce180f2867700b28921d99f9a0cb9c83330c91 (patch) | |
| tree | c563db507cce44b680996d42148185cb1512188c /src/server/game/Handlers/CharacterHandler.cpp | |
| parent | f85908869986eab0b645f0a697028bcceba7778c (diff) | |
Core/Logging: Add Asyncronous logging with Loggers ("What to log") and Appenders ("Where to log") system. Will allow to select to full log some parts of core while others are not even logged.
- Logging System is asyncronous to improve performance.
- Each msg and Logger has a Log Type and Log Level assigned. Each msg is assigned the Logger of same Log Type or "root" Logger is selected if there is no Logger configured for the given Log Type
- Loggers have a list of Appenders to send the msg to. The Msg in the Logger is not sent to Appenders if the msg LogLevel is lower than Logger LogLevel.
- There are three (at the moment) types of Appenders: Console, File or DB (this is WIP, not working ATM). Msg is not written to the resource if msg LogLevel is lower than Appender LogLevel.
- Appender and Console Log levels can be changed while server is active with command '.set loglevel (a/l) name level'
Explanation of use with Sample config:
Appender.Console.Type=1       (1 = Console)
Appender.Console.Level=2      (2 = Debug)
Appender.Server.Type=2        (2 = File)
Appender.Server.Level=3       (3 = Info)
Appender.Server.File=Server.log
Appender.SQL.Type=2           (2 = File)
Appender.SQL.Level=1          (1 = Trace)
Appender.SQL.File=sql.log
Appenders=Console Server      (NOTE: SQL has not been included here... that will make core ignore the config for "SQL" as it's not in this list)
Logger.root.Type=0            (0 = Default - if it's not created by config, server will create it with LogLevel = DISABLED)
Logger.root.Level=5           (5 = Error)
Logger.root.Appenders=Console
Logger.SQL.Type=26            (26 = SQL)
Logger.SQL.Level=3            (2 = Debug)
Logger.SQL.Appenders=Console Server SQL
Logger.SomeRandomName.Type=24 (24 = Guild)
Logger.SomeRandomName.Level=5 (5 = Error)
Loggers=root SQL SomeRandomName
* At loading Appender SQL will be ignored, as it's not present on "Appenders"
* sLog->outDebug(LOG_FILTER_GUILD, "Some log msg related to Guilds")
  - Msg is sent to Logger of Type LOG_FILTER_GUILD (24). Logger with name SomeRandomName is found but it's LogLevel = 5 and Msg LogLevel=2... Msg is not logged
* sLog->outError(LOG_FILTER_GUILD, "Some error log msg related to Guilds")
  - Msg is sent to Logger of Type LOG_FILTER_GUILD (24). Logger with name SomeRandomeName is found with proper LogLevel but Logger does not have any Appenders assigned to that logger... Msg is not logged
* sLog->outDebug(LOG_FILTER_SQL, "Some msg related to SQLs")
  - Msg is sent to Logger SQL (matches type), as it matches LogLevel the msg is sent to Appenders Console, Server and SQL
    - Appender Console has lower Log Level: Msg is logged to Console
    - Appender Server has higher Log Level: Msg is not logged to file
    - Appender SQL has lower Log Level: Msg is logged to file sql.log
* sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Some msg related to Battelgrounds")
  - Msg is sent to Logger root (Type 0) as no Logger was found with Type LOG_FILTER_BATTLEGROUND (13). As Logger has higher LogLevel msg is not sent to any appender
* sLog->outError(LOG_FILTER_BATTLEGROUND, "Some error msg related to Battelgrounds")
  - Msg is sent to Logger root (Type 0) as no Logger was found with Type LOG_FILTER_BATTLEGROUND (13). Msg has lower LogLevel and is sent to Appender Console
    - Appender Console has lower LogLevel: Msg is logged to Console
Diffstat (limited to 'src/server/game/Handlers/CharacterHandler.cpp')
| -rw-r--r-- | src/server/game/Handlers/CharacterHandler.cpp | 54 | 
1 files changed, 27 insertions, 27 deletions
| diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 29ee2b5cb41..df515f879f8 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -215,7 +215,7 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result)          do          {              uint32 guidlow = (*result)[0].GetUInt32(); -            sLog->outDetail("Loading char guid %u from account %u.", guidlow, GetAccountId()); +            sLog->outInfo(LOG_FILTER_NETWORKIO, "Loading char guid %u from account %u.", guidlow, GetAccountId());              if (Player::BuildEnumData(result, &data))              {                  _allowedCharsToLogin.insert(guidlow); @@ -293,7 +293,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data)      {          data << (uint8)CHAR_CREATE_FAILED;          SendPacket(&data); -        sLog->outError("Class (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", class_, GetAccountId()); +        sLog->outError(LOG_FILTER_NETWORKIO, "Class (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", class_, GetAccountId());          return;      } @@ -302,7 +302,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data)      {          data << (uint8)CHAR_CREATE_FAILED;          SendPacket(&data); -        sLog->outError("Race (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", race_, GetAccountId()); +        sLog->outError(LOG_FILTER_NETWORKIO, "Race (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", race_, GetAccountId());          return;      } @@ -310,7 +310,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data)      if (raceEntry->expansion > Expansion())      {          data << (uint8)CHAR_CREATE_EXPANSION; -        sLog->outError("Expansion %u account:[%d] tried to Create character with expansion %u race (%u)", Expansion(), GetAccountId(), raceEntry->expansion, race_); +        sLog->outError(LOG_FILTER_NETWORKIO, "Expansion %u account:[%d] tried to Create character with expansion %u race (%u)", Expansion(), GetAccountId(), raceEntry->expansion, race_);          SendPacket(&data);          return;      } @@ -319,7 +319,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data)      if (classEntry->expansion > Expansion())      {          data << (uint8)CHAR_CREATE_EXPANSION_CLASS; -        sLog->outError("Expansion %u account:[%d] tried to Create character with expansion %u class (%u)", Expansion(), GetAccountId(), classEntry->expansion, class_); +        sLog->outError(LOG_FILTER_NETWORKIO, "Expansion %u account:[%d] tried to Create character with expansion %u class (%u)", Expansion(), GetAccountId(), classEntry->expansion, class_);          SendPacket(&data);          return;      } @@ -348,7 +348,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data)      {          data << (uint8)CHAR_NAME_NO_NAME;          SendPacket(&data); -        sLog->outError("Account:[%d] but tried to Create character with empty [name] ", GetAccountId()); +        sLog->outError(LOG_FILTER_NETWORKIO, "Account:[%d] but tried to Create character with empty [name] ", GetAccountId());          return;      } @@ -658,8 +658,8 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte              SendPacket(&data);              std::string IP_str = GetRemoteAddress(); -            sLog->outDetail("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow()); -            sLog->outChar("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow()); +            sLog->outInfo(LOG_FILTER_NETWORKIO, "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow()); +            sLog->outDebug(LOG_FILTER_PLAYER, "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());              sScriptMgr->OnPlayerCreate(&newChar);              sWorld->AddCharacterNameData(newChar.GetGUIDLow(), std::string(newChar.GetName()), newChar.getGender(), newChar.getRace(), newChar.getClass()); @@ -719,16 +719,16 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data)          return;      std::string IP_str = GetRemoteAddress(); -    sLog->outDetail("Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid)); -    sLog->outChar("Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid)); +    sLog->outInfo(LOG_FILTER_NETWORKIO, "Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid)); +    sLog->outDebug(LOG_FILTER_PLAYER, "Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid));      sScriptMgr->OnPlayerDelete(guid);      sWorld->DeleteCharaceterNameData(GUID_LOPART(guid)); -    if (sLog->IsOutCharDump())                                // optimize GetPlayerDump call +    if (sLog->ShouldLog(LOG_FILTER_PLAYER, LOG_LEVEL_TRACE)) // optimize GetPlayerDump call      {          std::string dump;          if (PlayerDumpWriter().GetDump(GUID_LOPART(guid), dump)) -            sLog->outCharDump(dump.c_str(), GetAccountId(), GUID_LOPART(guid), name.c_str()); +            sLog->outTrace(LOG_FILTER_PLAYER, dump.c_str(), GetAccountId(), GUID_LOPART(guid), name.c_str());      }      Player::DeleteFromDB(guid, GetAccountId()); @@ -742,20 +742,20 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket & recv_data)  {      if (PlayerLoading() || GetPlayer() != NULL)      { -        sLog->outError("Player tryes to login again, AccountId = %d", GetAccountId()); +        sLog->outError(LOG_FILTER_NETWORKIO, "Player tryes to login again, AccountId = %d", GetAccountId());          return;      }      m_playerLoading = true;      uint64 playerGuid = 0; -    sLog->outStaticDebug("WORLD: Recvd Player Logon Message"); +    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd Player Logon Message");      recv_data >> playerGuid;      if (!CharCanLogin(GUID_LOPART(playerGuid)))      { -        sLog->outError("Account (%u) can't login with that character (%u).", GetAccountId(), GUID_LOPART(playerGuid)); +        sLog->outError(LOG_FILTER_NETWORKIO, "Account (%u) can't login with that character (%u).", GetAccountId(), GUID_LOPART(playerGuid));          KickPlayer();          return;      } @@ -839,13 +839,13 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)          data.put(0, linecount);          SendPacket(&data); -        sLog->outStaticDebug("WORLD: Sent motd (SMSG_MOTD)"); +        sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent motd (SMSG_MOTD)");          // send server info          if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)              chH.PSendSysMessage(_FULLVERSION); -        sLog->outStaticDebug("WORLD: Sent server info"); +        sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent server info");      }      //QueryResult* result = CharacterDatabase.PQuery("SELECT guildid, rank FROM guild_member WHERE guid = '%u'", pCurrChar->GetGUIDLow()); @@ -868,7 +868,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)          else          {              // remove wrong guild data -            sLog->outError("Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId()); +            sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId());              pCurrChar->SetInGuild(0);          }      } @@ -1006,7 +1006,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)          SendNotification(LANG_GM_ON);      std::string IP_str = GetRemoteAddress(); -    sLog->outChar("Account: %d (IP: %s) Login Character:[%s] (GUID: %u) Level: %d", +    sLog->outDebug(LOG_FILTER_PLAYER, "Account: %d (IP: %s) Login Character:[%s] (GUID: %u) Level: %d",          GetAccountId(), IP_str.c_str(), pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->getLevel());      if (!pCurrChar->IsStandState() && !pCurrChar->HasUnitState(UNIT_STATE_STUNNED)) @@ -1020,7 +1020,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)  void WorldSession::HandleSetFactionAtWar(WorldPacket & recv_data)  { -    sLog->outStaticDebug("WORLD: Received CMSG_SET_FACTION_ATWAR"); +    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SET_FACTION_ATWAR");      uint32 repListID;      uint8  flag; @@ -1034,7 +1034,7 @@ void WorldSession::HandleSetFactionAtWar(WorldPacket & recv_data)  //I think this function is never used :/ I dunno, but i guess this opcode not exists  void WorldSession::HandleSetFactionCheat(WorldPacket & /*recv_data*/)  { -    sLog->outError("WORLD SESSION: HandleSetFactionCheat, not expected call, please report."); +    sLog->outError(LOG_FILTER_NETWORKIO, "WORLD SESSION: HandleSetFactionCheat, not expected call, please report.");      GetPlayer()->GetReputationMgr().SendStates();  } @@ -1068,7 +1068,7 @@ void WorldSession::HandleTutorialReset(WorldPacket & /*recv_data*/)  void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data)  { -    sLog->outStaticDebug("WORLD: Received CMSG_SET_WATCHED_FACTION"); +    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SET_WATCHED_FACTION");      uint32 fact;      recv_data >> fact;      GetPlayer()->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fact); @@ -1076,7 +1076,7 @@ void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data)  void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recv_data)  { -    sLog->outStaticDebug("WORLD: Received CMSG_SET_FACTION_INACTIVE"); +    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SET_FACTION_INACTIVE");      uint32 replistid;      uint8 inactive;      recv_data >> replistid >> inactive; @@ -1086,14 +1086,14 @@ void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recv_data)  void WorldSession::HandleShowingHelmOpcode(WorldPacket& recv_data)  { -    sLog->outStaticDebug("CMSG_SHOWING_HELM for %s", _player->GetName()); +    sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SHOWING_HELM for %s", _player->GetName());      recv_data.read_skip<uint8>(); // unknown, bool?      _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM);  }  void WorldSession::HandleShowingCloakOpcode(WorldPacket& recv_data)  { -    sLog->outStaticDebug("CMSG_SHOWING_CLOAK for %s", _player->GetName()); +    sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SHOWING_CLOAK for %s", _player->GetName());      recv_data.read_skip<uint8>(); // unknown, bool?      _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK);  } @@ -1183,7 +1183,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu      CharacterDatabase.Execute(stmt); -    sLog->outChar("Account: %d (IP: %s) Character:[%s] (guid:%u) Changed name to: %s", GetAccountId(), GetRemoteAddress().c_str(), oldName.c_str(), guidLow, newName.c_str()); +    sLog->outDebug(LOG_FILTER_PLAYER, "Account: %d (IP: %s) Character:[%s] (guid:%u) Changed name to: %s", GetAccountId(), GetRemoteAddress().c_str(), oldName.c_str(), guidLow, newName.c_str());      WorldPacket data(SMSG_CHAR_RENAME, 1+8+(newName.size()+1));      data << uint8(RESPONSE_SUCCESS); @@ -1450,7 +1450,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)      if (result)      {          std::string oldname = result->Fetch()[0].GetString(); -        sLog->outChar("Account: %d (IP: %s), Character[%s] (guid:%u) Customized to: %s", GetAccountId(), GetRemoteAddress().c_str(), oldname.c_str(), GUID_LOPART(guid), newName.c_str()); +        sLog->outDebug(LOG_FILTER_PLAYER, "Account: %d (IP: %s), Character[%s] (guid:%u) Customized to: %s", GetAccountId(), GetRemoteAddress().c_str(), oldname.c_str(), GUID_LOPART(guid), newName.c_str());      }      Player::Customize(guid, gender, skin, face, hairStyle, hairColor, facialHair); | 
