This commit is contained in:
aozhiwei 2022-12-16 18:45:27 +08:00
parent a44b19b0c0
commit 7bd0372f4d
15 changed files with 80 additions and 62 deletions

View File

@ -8,6 +8,7 @@
#include <f8/netmsghandler.h>
#include <f8/msgqueue.h>
#include <f8/udplog.h>
#include "app.h"
#include "jsondatamgr.h"
@ -49,7 +50,7 @@ public:
}
if (warning) {
a8::UdpLog::Instance()->Warning("收到client非法数据包", {});
f8::UdpLog::Instance()->Warning("收到client非法数据包", {});
}
}
@ -83,7 +84,7 @@ static void CreateGameClientSocket(a8::TcpSession **p)
static void GSListeneron_error(a8::TcpListener*, int type, int errorid)
{
a8::UdpLog::Instance()->Debug("GGListeneron_error %d %d", {type, errorid});
f8::UdpLog::Instance()->Debug("GGListeneron_error %d %d", {type, errorid});
f8::MsgQueue::Instance()->PostMsg_r(IM_GGListenerError,
a8::XParams()
.SetParam1(errorid)

View File

@ -11,7 +11,8 @@
#include <a8/uuid.h>
#include <a8/collision.h>
#include "f8/netmsghandler.h"
#include <f8/udplog.h>
#include <f8/netmsghandler.h>
#include "app.h"
#include "jsondatamgr.h"
@ -66,7 +67,7 @@ const char* const PROJ_LOG_FILENAME_FMT = "log_$pid_%Y%m%d.log";
static void SavePerfLog()
{
a8::UdpLog::Instance()->Info
f8::UdpLog::Instance()->Info
("max_rundelay:%d room_num:%d player_num:%d online_num:%d alive_count:%d "
"sys_request_delay:%d user_request_delay:%d http_pending_num:%d real_alive_count:%d "
"account_num:%d level0_num:%d level1_num:%d "
@ -246,7 +247,7 @@ bool App::Init(int argc, char* argv[])
GGListener::Instance()->Init();
HttpProxy::Instance()->Init();
a8::UdpLog::Instance()->Info("gameserver starting instance_id:%d pid:%d debug_mode:%d channel:%d",
f8::UdpLog::Instance()->Info("gameserver starting instance_id:%d pid:%d debug_mode:%d channel:%d",
{
instance_id,
getpid(),
@ -310,7 +311,7 @@ void App::UnInit()
int App::Run()
{
int ret = 0;
a8::UdpLog::Instance()->Info("gameserver running", {});
f8::UdpLog::Instance()->Info("gameserver running", {});
last_run_tick_ = a8::XGetTickCount();
int delta_time = 0;
while (!terminated) {
@ -577,16 +578,16 @@ void App::InitLog()
a8::MkDir(proj_root_dir);
a8::MkDir(proj_log_root_dir);
a8::UdpLog::Instance()->SetLogFileName(log_file_name);
a8::UdpLog::Instance()->Init();
a8::UdpLog::Instance()->Info("proj_root_dir:%s", {proj_root_dir});
a8::UdpLog::Instance()->Info("proj_log_root_dir:%s", {proj_log_root_dir});
a8::UdpLog::Instance()->Info("log_file_name:%s", {log_file_name});
f8::UdpLog::Instance()->SetLogFileName(log_file_name);
f8::UdpLog::Instance()->Init();
f8::UdpLog::Instance()->Info("proj_root_dir:%s", {proj_root_dir});
f8::UdpLog::Instance()->Info("proj_log_root_dir:%s", {proj_log_root_dir});
f8::UdpLog::Instance()->Info("log_file_name:%s", {log_file_name});
}
void App::UnInitLog()
{
a8::UdpLog::Instance()->UnInit();
f8::UdpLog::Instance()->UnInit();
}
bool App::ParseOpt()

View File

@ -1,5 +1,7 @@
#include "precompile.h"
#include <f8/udplog.h>
#include "gridservice.h"
#include "human.h"
#include "room.h"
@ -236,7 +238,7 @@ bool GridService::InView(int grid_id, float x, float y)
bool in_view = InView(grid_id, b_grid_id);
#ifdef DEBUG
if (in_view) {
a8::UdpLog::Instance()->Debug("InView %d %d %f %f",
f8::UdpLog::Instance()->Debug("InView %d %d %f %f",
{
grid_id,
b_grid_id,

View File

@ -2,6 +2,8 @@
#include <a8/mutable_xobject.h>
#include <f8/udplog.h>
#include "handlermgr.h"
#include "GGListener.h"
@ -33,7 +35,7 @@ static void _GMOpsReload(f8::JsonHttpRequest* request)
request->resp_xobj->SetVal("errcode", 0);
request->resp_xobj->SetVal("errmsg", "");
JsonDataMgr::Instance()->Reload();
a8::UdpLog::Instance()->Info("reload config files", {});
f8::UdpLog::Instance()->Info("reload config files", {});
}
static void _GMOpsStopService(f8::JsonHttpRequest* request)

View File

@ -1,5 +1,7 @@
#include "precompile.h"
#include <f8/udplog.h>
#include "hero.h"
#include "human.h"
#include "room.h"
@ -303,7 +305,7 @@ void Hero::OnAddToTargetPartObject(Entity* target)
{
if (delete_frameno > 0) {
#if 1
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
("Hero::OnAddToTargetPartObject "
"delete_frameno:%d "
"room.frameno:%d",

View File

@ -3,6 +3,8 @@
#include <a8/sysutils.h>
#include <a8/mutable_xobject.h>
#include <f8/udplog.h>
#include "httpproxy.h"
#include "app.h"
#include "jsondatamgr.h"
@ -24,7 +26,7 @@ struct HttpProxyRequest
static void _ProxyCallback(f8::JsonHttpRequest* request)
{
//#ifdef DEBUG
a8::UdpLog::Instance()->Debug("ProxyCallbBack request:%s",
f8::UdpLog::Instance()->Debug("ProxyCallbBack request:%s",
{
request->request.ToJsonStr()
});
@ -99,7 +101,7 @@ std::string HttpProxy::HttpGet(a8::XParams param,
if (req) {
long long cost_time = a8::XGetTickCount() - req->add_tick;
#ifdef DEBUG
a8::UdpLog::Instance()->Debug("ProxyHttpGet ok cost_time:%d url:%s params:%s",
f8::UdpLog::Instance()->Debug("ProxyHttpGet ok cost_time:%d url:%s params:%s",
{
cost_time,
req->url,
@ -113,7 +115,7 @@ std::string HttpProxy::HttpGet(a8::XParams param,
HttpProxyRequest* req = HttpProxy::Instance()->GetRequest(param.sender.GetString());
if (req) {
long long cost_time = a8::XGetTickCount() - req->add_tick;
a8::UdpLog::Instance()->Warning("ProxyHttpGet error cost_time:%d url:%s params:%s response:%s",
f8::UdpLog::Instance()->Warning("ProxyHttpGet error cost_time:%d url:%s params:%s response:%s",
{
cost_time,
req->url,

View File

@ -6,7 +6,8 @@
#include <a8/mutable_xobject.h>
#include <a8/collision.h>
#include "f8/utils.h"
#include <f8/utils.h>
#include <f8/udplog.h>
#include "human.h"
#include "cs_proto.pb.h"
@ -588,7 +589,7 @@ void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data
if (!revive_timer.expired()) {
countdown = std::ceil(room->xtimer.GetRemainTime(revive_timer) / SERVER_FRAME_RATE);
} else {
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
("Human::FillMFObjectfull revive_timer == nullptr "
"dead_frameno:%d dead_times:%d alive_count:%d "
"room.frameno:%d",
@ -1521,7 +1522,7 @@ void Human::SyncAroundPlayers(const char* file, int line, const char* func)
#ifdef DEBUG
#if 0
room->CheckPartObjects();
a8::UdpLog::Instance()->Debug("room_idx:%d syncaround begin %s %d %s",
f8::UdpLog::Instance()->Debug("room_idx:%d syncaround begin %s %d %s",
{
room->GetRoomIdx(),
file,
@ -1542,14 +1543,14 @@ void Human::SyncAroundPlayers(const char* file, int line, const char* func)
for (auto& obj : hum->part_objects) {
objs_str += a8::Format("%d ", {(long long)obj});
}
a8::UdpLog::Instance()->Debug("hum1 %d %s", {(long long)hum, objs_str});
f8::UdpLog::Instance()->Debug("hum1 %d %s", {(long long)hum, objs_str});
}
{
std::string objs_str;
for (auto& obj : part_objects) {
objs_str += a8::Format("%d ", {(long long)obj});
}
a8::UdpLog::Instance()->Debug("hum2 %d %s", {(long long)this, objs_str});
f8::UdpLog::Instance()->Debug("hum2 %d %s", {(long long)this, objs_str});
}
room->CheckPartObjects(hum, this);
hum->InPartObjects(this);
@ -1560,7 +1561,7 @@ void Human::SyncAroundPlayers(const char* file, int line, const char* func)
static long long last_debugout_tick = 0;
if (a8::XGetTickCount() - last_debugout_tick > 1000 * 10) {
last_debugout_tick = a8::XGetTickCount();
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
("SyncAroundPlayers error room_idx:%d, file:%s line:%d func:%s",
{
room->GetRoomIdx(),
@ -1574,7 +1575,7 @@ void Human::SyncAroundPlayers(const char* file, int line, const char* func)
#ifdef DEBUG
#if 0
room->CheckPartObjects();
a8::UdpLog::Instance()->Debug("syncaround end %s %d %s",
f8::UdpLog::Instance()->Debug("syncaround end %s %d %s",
{
file,
line,
@ -2571,7 +2572,7 @@ void Human::SendBattleSettlement()
auto on_error =
[] (a8::XParams& param, const std::string& response)
{
a8::UdpLog::Instance()->Error("reportSettlement error params: %s response: %s",
f8::UdpLog::Instance()->Error("reportSettlement error params: %s response: %s",
{
param.param2,
response
@ -2647,7 +2648,7 @@ void Human::SendBattleReport()
auto on_error =
[] (a8::XParams& param, const std::string& response)
{
a8::UdpLog::Instance()->Error("battleReport http error params: %s response: %s",
f8::UdpLog::Instance()->Error("battleReport http error params: %s response: %s",
{
param.param2,
response
@ -3174,7 +3175,7 @@ void Human::ProcDecGridList(std::set<GridCell*>& old_grids,
c->AddOutObjects(this);
#ifdef DEBUG
#if 0
a8::UdpLog::Instance()->Debug("addoutobjects %d %d",
f8::UdpLog::Instance()->Debug("addoutobjects %d %d",
{
(long long)c,
c->GetUniId()

View File

@ -3,7 +3,8 @@
#include "jsondatamgr.h"
#include "app.h"
#include "f8/utils.h"
#include <f8/utils.h>
#include <f8/udplog.h>
void JsonDataMgr::Init()
{
@ -68,7 +69,7 @@ void JsonDataMgr::Init()
server_info = a8::Format("%s:%d", {ip, listen_port});
Reload();
a8::UdpLog::Instance()->Info("api_url:%s",
f8::UdpLog::Instance()->Info("api_url:%s",
{
api_url_
});

View File

@ -2,6 +2,8 @@
#include <math.h>
#include <f8/udplog.h>
#include "DetourCommon.h"
#include "mapinstance.h"
@ -69,7 +71,7 @@ void MapInstance::Init()
map_meta_->pb->map_height() / MAP_GRID_WIDTH,
MAP_GRID_WIDTH);
CreateThings();
a8::UdpLog::Instance()->Info
f8::UdpLog::Instance()->Info
("map_id:%d current_uniid:%d ",
{
map_id,

View File

@ -4,6 +4,8 @@
#include <float.h>
#include <a8/mutable_xobject.h>
#include <f8/udplog.h>
#include "playermgr.h"
#include "player.h"
#include "cs_proto.pb.h"
@ -746,7 +748,7 @@ void Player::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
respmsg.set_errmsg(TEXT("battle_server_reconnect_ok", "战斗重连成功"));
SendNotifyMsg(respmsg);
PlayerMgr::Instance()->ReBindSocket(this);
a8::UdpLog::Instance()->Debug
f8::UdpLog::Instance()->Debug
("战斗服重连成功 %s %d %d",
{
account_id,
@ -1533,7 +1535,7 @@ void Player::InternalRevive(int target_uniid, int revive_coin)
if (!dead_timer.expired()) {
room->xtimer.Delete(dead_timer);
}
a8::UdpLog::Instance()->Debug
f8::UdpLog::Instance()->Debug
("InternalRevive sender:%s target:%s pos:%f,%f",
{
account_id,

View File

@ -1,5 +1,7 @@
#include "precompile.h"
#include <f8/udplog.h>
#include "playermgr.h"
#include "player.h"
#include "cs_proto.pb.h"
@ -135,7 +137,7 @@ void PlayerMgr::IncAccountNum(const std::string& account_id)
if (itr != account_num_hash_.end()) {
++(itr->second);
if (itr->second > 3) {
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
(
"IncAccountNum account_id:%s num:%d > 3",
{
@ -155,7 +157,7 @@ void PlayerMgr::DecAccountNum(const std::string& account_id)
if (itr != account_num_hash_.end()) {
--(itr->second);
if (itr->second < 0) {
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
(
"DecAccountNum account_id:%s num:%d < 0",
{
@ -168,7 +170,7 @@ void PlayerMgr::DecAccountNum(const std::string& account_id)
account_num_hash_.erase(itr);
}
} else {
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
(
"DecAccountNum account_id:%s not exits",
{

View File

@ -1,7 +1,6 @@
#pragma once
#include <a8/a8.h>
#include <a8/udplog.h>
#include <a8/vec2.h>
#include <a8/vec3.h>

View File

@ -4,11 +4,11 @@
#include <a8/mutable_xobject.h>
#include <a8/timer.h>
#include <a8/udplog.h>
#include <a8/collision.h>
#include <a8/vec2.h>
#include "f8/utils.h"
#include <f8/udplog.h>
#include <f8/utils.h>
#include "playermgr.h"
#include "player.h"
@ -705,7 +705,7 @@ void Room::InternalRemoveObjectLater(Entity* entity, a8::Attacher& xtimer_attach
RemoveFromEntityHash(entity);
#ifdef DEBUG
#if 0
a8::UdpLog::Instance()->Debug
f8::UdpLog::Instance()->Debug
(
"remove object pointer:%d uniid:%d",
{
@ -1627,7 +1627,7 @@ void Room::CombineTeam()
Team* team1 = team_hash_[team_id1];
Team* team2 = team_hash_[team_id2];
if (team1->GetMemberNum() + team2->GetMemberNum() > MAX_TEAM_NUM) {
a8::UdpLog::Instance()->Warning("team_member > 4 :%d",
f8::UdpLog::Instance()->Warning("team_member > 4 :%d",
{
team1->GetMemberNum() + team2->GetMemberNum()
});
@ -2321,7 +2321,7 @@ void Room::EnableHuman(Human* target)
#ifdef DEBUG
CheckPartObjects();
#if 0
a8::UdpLog::Instance()->Debug("enablehuman %d %d",
f8::UdpLog::Instance()->Debug("enablehuman %d %d",
{
(long long)target,
target->GetUniId()
@ -2360,7 +2360,7 @@ void Room::DisableHuman(Human* target)
#ifdef DEBUG
CheckPartObjects();
#if 0
a8::UdpLog::Instance()->Debug("disablehuman %d %d",
f8::UdpLog::Instance()->Debug("disablehuman %d %d",
{
(long long)target,
target->GetUniId()
@ -2460,7 +2460,7 @@ void Room::ProcShuaAndroid(int shua_time, int shua_num)
return;
}
#ifdef DEBUG
a8::UdpLog::Instance()->Debug("ProcShuaAndroid room_idx:%d shua_time:%d shua_num%d real_shua_num:%d",
f8::UdpLog::Instance()->Debug("ProcShuaAndroid room_idx:%d shua_time:%d shua_num%d real_shua_num:%d",
{
GetRoomIdx(),
shua_time,
@ -2504,7 +2504,7 @@ void Room::ProcShuaAndroid(int shua_time, int shua_num)
void Room::ProcDieAndroid(int die_time, int die_num)
{
#ifdef DEBUG
a8::UdpLog::Instance()->Debug("ProcDieAndroid room_idx:%d die_time:%d die_num:%d",
f8::UdpLog::Instance()->Debug("ProcDieAndroid room_idx:%d die_time:%d die_num:%d",
{
GetRoomIdx(),
die_time,
@ -2719,7 +2719,7 @@ void Room::ShuaGridRound(Human* target)
}
}
#ifdef DEBUG
a8::UdpLog::Instance()->Debug("OnHumanGrid %d %d", {target->GetGridId(), count});
f8::UdpLog::Instance()->Debug("OnHumanGrid %d %d", {target->GetGridId(), count});
#endif
#ifdef DEBUG
CheckPartObjects();
@ -2855,7 +2855,7 @@ void Room::InitDebugInfo()
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
a8::UdpLog::Instance()->Debug("room_idx:%d real_alive_count:%d",
f8::UdpLog::Instance()->Debug("room_idx:%d real_alive_count:%d",
{
room->GetRoomIdx(),
room->RealAliveCount()
@ -2867,7 +2867,7 @@ void Room::InitDebugInfo()
void Room::UnInitDebugInfo()
{
#if 0
a8::UdpLog::Instance()->Debug("destroy room_idx:%d",
f8::UdpLog::Instance()->Debug("destroy room_idx:%d",
{
GetRoomIdx()
});
@ -3206,7 +3206,7 @@ void Room::CheckShowHand()
}
if (alive_count_ <= (int)(real_player_num + last_human_hash_.size())) {
#ifdef DEBUG
a8::UdpLog::Instance()->Debug
f8::UdpLog::Instance()->Debug
(
"showHand %d %d %d %d",
{
@ -3639,7 +3639,7 @@ void Room::AddTeam(class MatchTeam* team)
}
if (team->GetCurrMembers().size() != team->GetSlotNum()) {
#if 1
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
("addTeam currMembers.size:%d slot_num:%d",
{
team->GetCurrMembers().size(),

View File

@ -20,8 +20,9 @@
#include "httpproxy.h"
#include "config.h"
#include "f8/httpclientpool.h"
#include "f8/utils.h"
#include <f8/httpclientpool.h>
#include <f8/utils.h>
#include <f8/udplog.h>
const int ROOM_NUM_UP_LIMIT = 1000;
const int HUM_NUM_DOWN_LIMIT = 2500;
@ -215,7 +216,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
PlayerMgr::Instance()->IncAccountNum(msg.account_id());
if (JsonDataMgr::Instance()->channel != 0 &&
JsonDataMgr::Instance()->channel != channel) {
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
("join room channel not match channel:%d account_id:%s",
{
JsonDataMgr::Instance()->channel,
@ -252,7 +253,7 @@ void RoomMgr::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
if (!room) {
send_reconnect_failed(hdr.socket_handle, 1,
TEXT("battle_server_reconnect_failreason_room_destoryed", "房间已销毁"));
a8::UdpLog::Instance()->Debug
f8::UdpLog::Instance()->Debug
("房间已销毁 %s",
{
msg.room_uuid()
@ -593,7 +594,7 @@ Room* RoomMgr::CreateRoom(const cs::CMJoin& msg,
room_idx_hash_[room->GetRoomIdx()] = room;
++PerfMonitor::Instance()->room_num[room->GetRoomType()];
#ifdef DEBUG
a8::UdpLog::Instance()->Debug("createroom room_idx:%d room_uuid:%d room_type:%d",
f8::UdpLog::Instance()->Debug("createroom room_idx:%d room_uuid:%d room_type:%d",
{
room->GetRoomIdx(),
room->GetRoomUuid(),
@ -620,7 +621,7 @@ void RoomMgr::JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_
GGListener::Instance()->ForceCloseChildSocket(param.sender);
});
}
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
("join error errcode:%d accountid:%s max_mainloop_rundelay:%d "
"room_num:%d player_num:%d online_num:%d",
{
@ -694,7 +695,7 @@ void RoomMgr::OnJoinRoomOk(const cs::CMJoin& msg, Player* hum)
if (itr != team_hash->end()) {
itr->second = hum->room->GetRoomUuid();
} else {
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
("team_data:%s account_id:%s not exists",
{
GenTeamHashData(msg.team_uuid(), team_hash),
@ -722,7 +723,7 @@ void RoomMgr::TeamRoomTimeOut(const std::string& team_uuid)
}
}
if (!ok) {
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
("team match failed team_data:%s ",
{
GenTeamHashData(team_uuid, team_hash),
@ -730,7 +731,7 @@ void RoomMgr::TeamRoomTimeOut(const std::string& team_uuid)
}
team_room_hash_.erase(team_uuid);
} else {
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
("team not found team_uuid:s",
{
team_uuid
@ -801,7 +802,7 @@ void RoomMgr::SendGetBattleData(int mode,
void(std::vector<std::shared_ptr<BattleDataContext>>&)>(cb)),
[] (a8::XParams& param, a8::XObject& data)
{
a8::UdpLog::Instance()->Info
f8::UdpLog::Instance()->Info
("GetBattleData ok %s",
{
data.ToJsonStr()
@ -833,7 +834,7 @@ void RoomMgr::SendGetBattleData(int mode,
},
[] (a8::XParams& param, const std::string& response)
{
a8::UdpLog::Instance()->Warning
f8::UdpLog::Instance()->Warning
("GetBattleData error %s",
{
response

2
third_party/f8 vendored

@ -1 +1 @@
Subproject commit 42651a1c9b0c841b11b0f32734c27e8d5bd6312d
Subproject commit b9b2211ab22634684728d05f8117bd96c0714a25