You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.5 KiB
96 lines
3.5 KiB
using System;
|
|
using ProtoCSStruct;
|
|
using ThinkingData.Analytics;
|
|
namespace Sog.Log
|
|
{
|
|
/// <summary>
|
|
/// 把运营日志写到BillLogServer
|
|
/// </summary>
|
|
public class BillLogWriter : Singleton<BillLogWriter>
|
|
{
|
|
//taSdk暂时放在这把
|
|
public ThinkingdataAnalytics m_taSdk = new ThinkingdataAnalytics(new SogConsumer(), true);
|
|
|
|
private uint m_billLogSvrID;
|
|
private StructPacketSender m_structPacketSender;
|
|
|
|
SSBillLogReq billLogReq = new SSBillLogReq();
|
|
|
|
SSBDCLogReq bdcLogReq = new SSBDCLogReq();
|
|
|
|
SSTALogReq taLogReq = new SSTALogReq();
|
|
|
|
public void Init(uint serverID, StructPacketSender packetSender)
|
|
{
|
|
// cluster层的accountbill有主备两套, 根据instId来连接
|
|
if (ServerIDUtils.GetWorldID(serverID) == 0)
|
|
{
|
|
int clusterInstId = (int)ServerIDUtils.GetInstanceID(serverID);
|
|
m_billLogSvrID = ServerIDUtils.GetLevel0ServerIDByType((int)ServerType.AccountBillLog, clusterInstId);
|
|
}
|
|
else
|
|
{
|
|
m_billLogSvrID = ServerIDUtils.GetLevel1ServerIDByType(serverID, (int)ServerType.BillLog, 1);
|
|
}
|
|
|
|
m_structPacketSender = packetSender;
|
|
}
|
|
|
|
public ThinkingdataAnalytics GetTASDK()
|
|
{
|
|
return m_taSdk;
|
|
}
|
|
public void SendCliToBillBDCLogSvr(StructPacket packet)
|
|
{
|
|
m_structPacketSender.SendToServerByID<CsLogClientBDCReq>(m_billLogSvrID, packet);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 注意,这个不是线程安全的
|
|
/// </summary>
|
|
/// <param name="uid"></param>
|
|
/// <param name="logMessage"></param>
|
|
public void SendToBillLogSvr(long uid, string logMessage)
|
|
{
|
|
TraceLog.UserTrace(uid, "BillLogWriter.SendToBillLogSvr {0}", logMessage);
|
|
|
|
billLogReq.Clear();
|
|
billLogReq.StrLogMessage.SetString(logMessage);
|
|
|
|
m_structPacketSender.SendToServerByID(m_billLogSvrID
|
|
, (int)SSGameMsgID.BillLogReq
|
|
, ref billLogReq
|
|
, uid
|
|
, 0);
|
|
}
|
|
|
|
public void SendBDCToBillLogSvr(long uid, string logMessage, int eventId)
|
|
{
|
|
//TraceLog.UserTraceDetail(uid, "BillLogWriter.SendBDCToBillLogSvr {0}", logMessage);
|
|
|
|
bdcLogReq.Clear();
|
|
bdcLogReq.LogMsg.SetString(logMessage);
|
|
bdcLogReq.EventId = eventId;
|
|
//m_structPacketSender.SendToServerByID(m_billLogSvrID, (int) CSGameMsgID.LogClientBdcReq, ref bdcLogReq, uid);
|
|
m_structPacketSender.SendToServerByID(m_billLogSvrID, (int) SSGameMsgID.BdcLogReq, ref bdcLogReq, uid);
|
|
}
|
|
|
|
public void SendCliToBillTALogSvr(StructPacket packet)
|
|
{
|
|
m_structPacketSender.SendToServerByID<CsLogClientTAReq>(m_billLogSvrID, packet);
|
|
}
|
|
public void SendTAToBillLogSvr(long uid, string logMessage, string event_name)
|
|
{
|
|
//TraceLog.UserTraceDetail(uid, "BillLogWriter.SendBDCToBillLogSvr {0}", logMessage);
|
|
|
|
taLogReq.Clear();
|
|
taLogReq.LogMsg.SetString(logMessage);
|
|
if(!string.IsNullOrEmpty(event_name))
|
|
{
|
|
taLogReq.EventName.SetString(event_name);
|
|
}
|
|
//m_structPacketSender.SendToServerByID(m_billLogSvrID, (int) CSGameMsgID.LogClientBdcReq, ref bdcLogReq, uid);
|
|
m_structPacketSender.SendToServerByID(m_billLogSvrID, (int)SSGameMsgID.TaLogReq, ref taLogReq, uid);
|
|
}
|
|
}
|
|
}
|
|
|