1 Star 0 Fork 121

blog/kbengine

forked from likecg/kbengine 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
logger.h 2.82 KB
一键复制 编辑 原始数据 按行查看 历史
liquidx 提交于 2014-12-29 15:19 +08:00 . up
/*
This source file is part of KBEngine
For the latest info, see http://www.kbengine.org/
Copyright (c) 2008-2012 KBEngine.
KBEngine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KBEngine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KBE_LOGGER_H
#define KBE_LOGGER_H
// common include
#include "server/kbemain.h"
#include "server/serverapp.h"
#include "server/idallocate.h"
#include "server/serverconfig.h"
#include "common/timer.h"
#include "network/endpoint.h"
#include "network/udp_packet_receiver.h"
#include "network/common.h"
#include "network/address.h"
#include "logwatcher.h"
//#define NDEBUG
#include <map>
// windows include
#if KBE_PLATFORM == PLATFORM_WIN32
#else
// linux include
#endif
namespace KBEngine{
struct LOG_ITEM
{
int32 uid;
uint32 logtype;
COMPONENT_TYPE componentType;
COMPONENT_ID componentID;
COMPONENT_ORDER componentGlobalOrder;
COMPONENT_ORDER componentGroupOrder;
int64 t;
GAME_TIME kbetime;
std::stringstream logstream;
};
class Logger: public ServerApp,
public Singleton<Logger>
{
public:
typedef std::map<Network::Address, LogWatcher> LOG_WATCHERS;
public:
enum TimeOutType
{
TIMEOUT_GAME_TICK = TIMEOUT_SERVERAPP_MAX + 1
};
Logger(Network::EventDispatcher& dispatcher,
Network::NetworkInterface& ninterface,
COMPONENT_TYPE componentType,
COMPONENT_ID componentID);
~Logger();
bool run();
void handleTimeout(TimerHandle handle, void * arg);
/* 初始化相关接口 */
bool initializeBegin();
bool inInitialize();
bool initializeEnd();
void finalise();
virtual bool canShutdown();
/** 网络接口
写日志
*/
void writeLog(Network::Channel* pChannel, KBEngine::MemoryStream& s);
/** 网络接口
注册log监听者
*/
void registerLogWatcher(Network::Channel* pChannel, KBEngine::MemoryStream& s);
/** 网络接口
注销log监听者
*/
void deregisterLogWatcher(Network::Channel* pChannel, KBEngine::MemoryStream& s);
/** 网络接口
log监听者更新自己的设置
*/
void updateLogWatcherSetting(Network::Channel* pChannel, KBEngine::MemoryStream& s);
LOG_WATCHERS& logWatchers(){ return logWatchers_; }
void sendInitLogs(LogWatcher& logWatcher);
protected:
LOG_WATCHERS logWatchers_;
std::deque<LOG_ITEM*> buffered_logs_;
};
}
#endif // KBE_LOGGER_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/blog/kbengine.git
git@gitee.com:blog/kbengine.git
blog
kbengine
kbengine
79b13fda735e573bcbf7f47457634b77cf597d00

搜索帮助