From 39bcd7ca0c7586e8f2403dd228d8d0188b4af7e5 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Fri, 21 Aug 2020 14:41:10 +0800 Subject: [PATCH] LOG --- src/actions/EmailAction.lua | 39 ++++++++++++++++----------------------- src/actions/RoleAction.lua | 56 +++++++++++++++++++++++++++++++++++++++----------------- src/actions/StoreAction.lua | 17 +++++++++++++++++ src/agent.lua | 2 +- src/models/Email.lua | 17 +++++++++++++++++ src/models/RoleLog.lua | 654 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/models/RolePlugin.lua | 68 +++++++++++++++++++++++++++++++++++++++----------------------------- src/services/agent_ctrl.lua | 2 +- src/services/logd.lua | 31 ++----------------------------- 9 files changed, 601 insertions(+), 285 deletions(-) diff --git a/src/actions/EmailAction.lua b/src/actions/EmailAction.lua index b26515f..25e21ff 100644 --- a/src/actions/EmailAction.lua +++ b/src/actions/EmailAction.lua @@ -53,7 +53,6 @@ function _M.listRpc(agent, data) content = email.content, attachments = email.attachments }) - role:log("mail_action", {desc = "get_global", key1 = email.title, key2 = email.attachments}) end end end @@ -90,21 +89,17 @@ function _M.drawAllAttachRpc(agent, data) local ids = {} local emails = loadEmails(roleId) - redisproxy:pipelining(function (red) - for _, email in ipairs(emails) do - local attachments = getEmailAttachments(email) - if attachments ~= "" then - local emailId = email:getProperty("id") - ids[emailId] = 1 - red:hset(string.format(R_EMAIL_ITEM, roleId, emailId), "status", 2) - role:log("mail_action", {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title"), key2 = attachments}) - - for key, v in pairs(attachments:toNumMap()) do - reward[key] = (reward[key] or 0) + v - end + for _, email in ipairs(emails) do + local attachments = getEmailAttachments(email) + if attachments ~= "" then + email:setProperty("status", 2) + email:log(role, 2) + ids[emailId] = 1 + for key, v in pairs(attachments:toNumMap()) do + reward[key] = (reward[key] or 0) + v end end - end) + end reward, change = role:award(reward, {log = {desc = "draw_attach"}}) SendPacket(actionCodes.Email_drawAllAttachRpc, MsgPack.pack({ids = ids, reward = reward, change = change})) return true @@ -125,10 +120,10 @@ function _M.drawAttachRpc(agent, data) if attachments == "" then return end local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title")}}) - redisproxy:hset(rds, "status", 2) -- 领取标记 + email:setProperty("status", 2) + email:log(role, 2) SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) - role:log("mail_action", {desc = "draw_attach", int1 = id, key1 = email:getProperty("title"), key2 = attachments}) return true end @@ -139,11 +134,11 @@ function _M.checkRpc(agent, data) local msg = MsgPack.unpack(data) local id = msg.id - local rds = string.format(R_EMAIL_ITEM, roleId, id) - if not redisproxy:exists(rds) then return end + local email = require("models.Email").new({key = rds}) + if not email:load() then return end - redisproxy:hset(rds, "status", 1) - role:log("mail_action", {desc = "check_mail", int1 = id}) + email:setProperty(rds, "status", 1) + email:log(role, 1) SendPacket(actionCodes.Email_checkRpc, '') return true @@ -171,6 +166,7 @@ function _M.delRpc(agent, data) attachments = emailData.attachment end if status == 2 or (status == 1 and attachments:len() == 0) then + email:log(role, 3) red:lrem(rds, 0, id) red:del(emailRds) result[tonum(id)] = 1 @@ -178,9 +174,6 @@ function _M.delRpc(agent, data) end end end) - for delId, _ in ipairs(result) do - role:log("mail_action", {desc = "del_mail", int1 = delId}) - end SendPacket(actionCodes.Email_delRpc, MsgPack.pack({result = result})) return true end diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index cdd14d1..cdba387 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -99,6 +99,29 @@ function _M.loginRpc( agent, data ) role:reloadWhenLogin() end + + role.sysVersion = msg.sysVersion + role.ip = agent.ip:toArray(false, ":")[1] + role.clientVersion = msg.clientVersion + role.network = msg.network + + if msg.subId then + role:setProperty("sid", msg.subId) + end + + if msg.deviceMode then + local deviceMode = tostring(msg.deviceMode) + if role:getProperty("dmode") ~= deviceMode then + role:setProperty("dmode", deviceMode) + end + end + if msg.device then + local device = tostring(msg.device) + if role:getProperty("device") ~= device then + role:setProperty("device", device) + end + end + if not msg.isGMlogin then local banTime = role:getProperty("banTime") if banTime > now then @@ -114,18 +137,7 @@ function _M.loginRpc( agent, data ) role:setBan(0) end end - if msg.deviceMode then - local deviceMode = tostring(msg.deviceMode) - if role:getProperty("dmode") ~= deviceMode then - role:setProperty("dmode", deviceMode) - end - end - if msg.device then - local device = tostring(msg.device) - if role:getProperty("device") ~= device then - role:setProperty("device", device) - end - end + SERV_OPEN = redisproxy:hget("autoincrement_set", "server_start") @@ -266,7 +278,7 @@ function _M.loginRpc( agent, data ) role:savePvpHTeam() local hangPass = role:getProperty("hangPass") - role:log("login", {key1 = agent.ip:toArray(false, ":")[1], int1 = hangPass[1] or 0}) + role:log("onLogin") return true end @@ -314,11 +326,20 @@ function _M.createRpc(agent, data) return true end newRole:startActionUcode() + newRole.sysVersion = msg.sysVersion + newRole.ip = agent.ip:toArray(false, ":")[1] + newRole.clientVersion = msg.clientVersion + newRole.network = msg.network + newRole:award(globalCsv.birthItem, {log = {desc = "birth"}, notNotify = true}) -- 欢迎邮件 redisproxy:insertEmail({roleId = roleId, emailId = 1}) - newRole:log("create", {key1 = agent.ip:toArray(false, ":")[1]}) + if msg.newuser then + newRole:log("onCreateAccount") + end + newRole:log("onCreateRole") + SendPacket(actionCodes.Role_createRpc, MsgPack.pack(response)) return true @@ -1011,6 +1032,7 @@ function _M.guideRpc(agent, data) role:saveGuide(master, slave) funcGuide = funcGuide:setv(master * 1000 + slave, 1) role:updateProperty({field = "funcGuide", value = funcGuide}) + role:log("onGuidePoint", {guild_type = 0, guild_id = master, guild_point = slave, guild_pass = 0}) elseif cmdType == 2 then -- 系统引导(玩家可选择是否进行) if not msg.skip then return end @@ -1023,7 +1045,7 @@ function _M.guideRpc(agent, data) if msg.funcType then funcGuide = funcGuide:setv(msg.funcType, 1) - role:log("guide", {desc = "guide_weak", int1 = msg.funcType}) + role:log("onGuidePoint", {guild_type = 2, guild_id = msg.funcType, guild_point = 0, guild_pass = 0}) end role:updateProperty({field = "funcGuide", value = funcGuide}) elseif cmdType == 3 then @@ -1032,14 +1054,14 @@ function _M.guideRpc(agent, data) role:saveGuide(csvdb["guide_unlockCsv"][msg.funcType].guideId,1) funcGuide = funcGuide:setv(msg.funcType, 1) role:updateProperty({field = "funcGuide", value = funcGuide}) - role:log("guide", {desc = "guide_sys", int1 = funcIdx}) + role:log("onGuidePoint", {guild_type = 1, guild_id = msg.funcType, guild_point = 0, guild_pass = 0}) end elseif cmdType == 4 then -- 弹出一个tips(进入功能界面也许要自动弹说明,value要区分1、2) if msg.funcType then local value = msg.value or 1 for _, funcIdx in pairs(msg.funcType:toArray(true,"=")) do - role:log("guide", {desc = "guide_tips", int1 = funcIdx}) + role:log("onGuidePoint", {guild_type = 3, guild_id = funcIdx, guild_point = 0, guild_pass = 0}) funcGuide = funcGuide:setv(funcIdx, value) end role:updateProperty({field = "funcGuide", value = funcGuide}) diff --git a/src/actions/StoreAction.lua b/src/actions/StoreAction.lua index bb55ffb..0545987 100644 --- a/src/actions/StoreAction.lua +++ b/src/actions/StoreAction.lua @@ -31,6 +31,7 @@ function _M.rechargeRpc(agent , data) local partnerOrderId = makeOrder(roleId, id) SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) + -- 测试的 直接发奖励了 skynet.timeout(10, function () role:handlePurchase({ @@ -164,6 +165,22 @@ function _M.purchaseOrderResult(agent, data) if msg.status == "success" then orderObject:setProperty("transactionId", msg.platformOrder or "") + local rechargeId = orderObject:getProperty("rechargeId") + local dataSet = csvdb["shop_rechargeCsv"][rechargeId] + + role:log("setOrder", { + order_status = 100, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他" + item_id = rechargeId, -- 道具id + item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表 + item_name = dataSet.title, -- 购买的道具名 + item_number = 1, -- 购买的道具数量 + item_level = 1, -- 购买的道具等级 + order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee' + order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范 + order_type = self.getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0 + order_id = msg.platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no' + }) + return true end diff --git a/src/agent.lua b/src/agent.lua index fe486a8..d536dc3 100644 --- a/src/agent.lua +++ b/src/agent.lua @@ -282,7 +282,7 @@ function CMD.close() mcast_util.usub_union() local role = agentInfo.role if not role then return end - role:log("logout", {int1 = skynet.timex()-role:getProperty("ltime")}) + role:log("onLogout", {logtime = skynet.timex()-role:getProperty("ltime")}) role:onOfflineEvent() end diff --git a/src/models/Email.lua b/src/models/Email.lua index 359982d..f593395 100644 --- a/src/models/Email.lua +++ b/src/models/Email.lua @@ -18,6 +18,23 @@ Email.schema = { rewardPms = {"table", {}}, } +function Email:log(role, action) + role:log("onMail", { + mail_action_type = action, -- 操作(1=收,2=领,3=删) + mail_receivetime = self:getProperty("createtime"), -- 收件时间 + mail_textid = self:getProperty("emailId"), -- 邮件文本ID + mial_title = self:getProperty("title"), -- 邮件标题参数 + mail_content = json.encode(self:getProperty("contentPms")), -- 邮件内容参数 + mail_attach = self:getProperty("attachments"), -- 邮件附件 + mail_reason = self:getProperty("stitle"), -- 原因 + mail_readstatus = self:getProperty("status") >= 1 and 1 or 0, -- 邮件读取状态 + mail_attachstatus = self:getProperty("status") >= 2 and 1 or 0, -- 邮件附件状态 + mail_timeout = 0, -- 邮件超时时间 + mail_friend_id = 0, -- 收件方账号id + mail_friend_roleid = 0, -- 收件方角色id + }) +end + function Email:data() local emailId = self:getProperty("emailId") local title = self:getProperty("title") diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index faadc5f..5cffee6 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -1,214 +1,497 @@ +local server_id = (skynet.getenv("serverType") or "localtest") .. "_" .. skynet.getenv("servId") --- logType -local LogType = { - create = "common", - login = "common", - logout = "common", - guide = "common", +--[[ + 100 购买/兑换行为 + 200 交易行为(与其他玩家) + 300 通过关卡产出或消耗 + 400 通过任务产出或消耗 + 500 通过公会产出或消耗 + 600 通过成就产出或消耗 + 700 通过邮件产出或消耗 + 1000 其他行为 +--]] +local ItemReason = { + advWheelSurf = 101, -- 资助 + advRepayWheelSurf = 102, -- 资助回馈 + saleEquip = 103, -- 卖装备 + saleRune = 104, -- 卖铭文 + drawHero = 105, -- 抽卡 + pvpShop = 106, -- pvp商店 + saleItem = 107, -- 售卖道具 + openItem = 108, -- 打开箱子 + openTimeBox = 109, -- 打开时间箱 + speedUpBox = 110, -- 速度箱 + dailyShop = 111, -- 每日商城 + dinershop = 112, -- 餐厅商店 + goldBuy = 113, -- 购买金币 + buyAdvCount = 114, -- 购买冒险次数 + advReSupport = 115, -- 刷新拾荒支援技 + advQuickHang = 116, -- 冒险快速挂机 + makePotion = 117, -- 制造药剂 + equipUp = 118, -- 装备升级 + runeUp = 119, -- 符文升级 + talentUp = 120, -- 天赋升级 + buyBonusCount = 121, -- 购买奖励副本次数 + bagField = 122, -- 背包栏位 + buyPvpKey = 123, -- 购买pvp钥匙 + startPvp = 124, -- 开始pvp + unlockStory = 125, -- 解锁剧情 + towerCount = 126, -- 电波塔次数 + + advHang = 301, -- 拾荒挂机 + hangBattle = 302, -- 挂机战斗 + hangReward = 303, -- 挂机奖励 + quickHang = 304, -- 快速挂机 + bonusBattle = 305, -- 奖励副本 + hangGift = 306, -- 奖励关卡奖励 + pvpBattleC = 307, -- pvp战斗普通 + pvpBattleH = 308, -- pvp战斗高级 + pvpDivisionH = 309, -- pvp高级段位奖励 + towerBattle = 310, -- 电波塔战斗 + advOver = 311, -- 冒险结算 + advUnlock = 312, -- 拾荒解锁 - in_item = "common", - out_item = "common", - in_diamond = "common", - out_diamond = "common", - in_hero = "common", - out_hero = "common", - in_equip = "common", - out_equip = "common", - in_rune = "common", - out_rune = "common", - player_exp = "common", - func_open = "common", - in_adv = "common", - out_adv = "common", - in_artifact = "common", - - mail_action = "common", - role_action = "common", - hang_action = "common", - hero_action = "common", - adv_action = "common", - rune_action = "common", - pvp_action = "common", - diner_action = "common", - tower_action = "common", - gm_action = "common", - act_action = "common", + dinerFinishTask = 401, -- 餐厅完成任务 + storybookReward = 402, -- 剧情奖励 + finishTask = 403, -- 任务 + taskActive = 404, -- 完成活跃任务 + advMainTask = 405, -- 拾荒主线 + + finishAchive = 601, -- 完成成就 + advAchiev = 602, -- 拾荒成就 + advAchievReward = 603, -- 拾慌成就奖励 + + draw_attach = 701, -- 邮件奖励 + + gm = 1000, -- 获取途径:GM + + -- 活动 + sudoku = 1001, -- 九宫格 + sudokuR = 1002, -- 九宫格连线奖励 + sudokuRP = 1003, -- 九宫格阶段奖励 + sign = 1004, -- 签到 + friendPoint = 1005, -- 友情 + birth = 1006, -- 出生奖励 + + -- 餐厅 + greenHourse = 1101, -- 食材获得 + dinerEntrus = 1102, -- 餐厅委托 + dinerCollect = 1103, -- 餐厅小人收集 + dinerCombo = 1104, -- 小人组合 + dinerSkillUp = 1105, -- 餐厅技能升级 + dinerReTask = 1106, -- 餐厅刷新任务 + addSell = 1107, -- 餐厅贩卖 + dinerBuildUp = 1108, -- 建筑升级 + removeSell = 1109, -- 移除售卖 + dinerSell = 1110, -- 餐饮售卖 + + -- 英雄 + heroLevelUp = 1201, -- 英雄升级 + heroBreak = 1202, -- 英雄突破 + heroWake = 1203, -- 英雄觉醒 + heroTalent = 1204, -- 英雄天赋 + createHero = 1205, -- 碎片合成 + createHeroRandom = 1206, -- 随机合成 + resetHero = 1207, -- 重置养成 } --- 如要修改 要提前修改 _template mapping -- 对应 mapping 为 gamelog-* -local Mapping = { - -- 预留一些数据格式 担心integer 范围不够用 将 通用的int* 全部换为long - common = { - desc = "keyword",--索引的短字符串 - ucode = "keyword",--关联日志对应ucode - key1 = "keyword", --可索引的短字符串 - key2 = "keyword", --可索引的短字符串 - -- 几乎不用的长文本 - text1 = "text", --长字符串不索引的类型 - -- 五个不同类型的数字 基本上满足数量要求 尽量从低到高用 - short1 = "short", - int1 = "long", - int2 = "long", - long1 = "long", - float1 = "float", - - -- 底层使用的 一些参数 - cint1 = "long", - cint2 = "long", - cint3 = "long", - } + +--[[ +100 教学 +200 主线 +300 日常 +400 周常 +500 联盟 +1000 限时任务 +2000 其他 +--]] +local TaskType = { + } --- 所有的日志都包括的部分 role 里面的信息 -- mapping 信息在 gamelog-role -local commonRoleField = { - name = "keyword", - id = "integer", - uid = "keyword", - sid = "short", - device = "keyword", - ctime = "integer", - ltime = "integer", - level = "short", - rmbC = "integer", + +local MethodType = { + onCreateAccount = {}, -- 创建游戏账号 + onCreateRole = {}, -- 创建游戏角色 + onLogin = {}, -- 玩家登录 + onLogout = { -- 登出 + logtime = true, --登录时长 + }, + setLevel = { -- 设置等级 --TODO + level_before = true, -- 变动前的等级,可以跳级 + level_changemain = true, -- 等级变动原因,副本通关:mission,领取奖励:reward + level_changedetail = true, -- 等级变动原因明细,副本通关则记录关卡ID,领取奖励则记录奖励ID + level_reward = true, -- 等级变动奖励,json格式记录,{道具ID1:道具数量,道具ID2:道具数量} + }, + onGuidePoint = { --游戏引导 + guild_type = true, --引导类型,新手引导:0,系统引导:1,弱引导:2 + guild_id = true, --节点ID + guild_point = true, --步骤ID + guild_pass = true, --正常操作:0,自动播放:1,跳过:2 + }, + setOrder = { --玩家订单记录 + order_status = true, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他" + item_id = true, -- 道具id + item_type = true, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表 + item_name = true, -- 购买的道具名 + item_number = true, -- 购买的道具数量 + item_level = true, -- 购买的道具等级 + order_cost = true, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee' + order_currency = true, -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范 + order_type = true, -- 订单类型,首充记录为1,否则为0 + order_id = true, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no' + }, + onMail = { --玩家邮件操作 + mail_action_type = true, -- 操作(1=收,2=领,3=删) + mail_receivetime = true, -- 收件时间 + mail_textid = true, -- 邮件文本ID + mial_title = true, -- 邮件标题参数 + mail_content = true, -- 邮件内容参数 + mail_attach = true, -- 邮件附件 + mail_reason = true, -- 原因 + mail_readstatus = true, -- 邮件读取状态 + mail_attachstatus = true, -- 邮件附件状态 + mail_timeout = true, -- 邮件超时时间 + mail_friend_id = true, -- 收件方账号id + mail_friend_roleid = true, -- 收件方角色id + }, + onItems = { --道具流通 --TODO + item_id = true, -- 道具id + item_sequenceid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个礼包多个物品等情形 + item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表 + item_level = true, -- 道具等级 + item_number = true, -- 道具变化数量的绝对值 + action_type = true, -- 变化类型(玩家获取:1,玩家消耗:0) + item_before = true, -- 道具变化前的数量 + item_after = true, -- 道具变化后的数量 + item_reason = true, -- 道具流动一级原因,如抽卡、装备强化、副本掉落,可参考道具动作类型枚举表 + item_subreason = true, -- 道具流动二级原因,抽卡:卡池ID,装备强化:装备ID,副本掉落:副本ID + item_other = true, -- 其他(可包含阶数,强化等级,随机属性) + }, + mission = { --玩家副本完成情况 --TODO + mission_threadid = true, -- 大关卡ID + mission_id = true, -- 关卡ID + mission_type = true, -- 关卡类型,见关卡类型枚举表 + mission_sequenceid = "ucode", -- 本次对战ID,用于关联一次动作产生多条不同类型的日志 + mission_herolist = true, -- 英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] + mission_heroscore = true, -- 编队总评分 + mission_enemylist = true, -- 地方英雄ID,排序以玩家出战设置为准,PVP多个队伍则记录多个列表。示例:[[1,2,3],[456]] + mission_damage = true, -- 英雄输出值。示例:{'heroid1':1000,'heroid2':2000,………..} + mission_ultskill = true, -- 大招使用情况。示例:{'heroid1':1000,'heroid2':2000,………..} + mission_reward = true, -- 获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + mission_starttime = true, -- 战斗开始时间,格式 unixtime 秒级 + mission_roundtime = true, -- 对局时长(秒) + mission_result = true, -- 战斗结果(0-无效,1-胜利,2-失败) + mission_star = true, -- 战斗完成星数,无星级的话填写0 + mission_restriction = true, -- 周期内参与限制(0表示没有上限) + mission_difficulty = true, -- 关卡困难度,无难度区分的话填写0 + mission_strength = true, -- 消耗的体力或次数 + mission_score = true, -- 本局分数,PVP玩法记录为对战后积分,无得分的填0 + mission_cleartype = true, -- 1正常通关;2代理拾荒 + mission_rank = true, -- 对战后排名,适用于PVP玩法和电波塔,其他玩法留空 + misson_monsterkill = true, -- 击杀怪物ID和数量,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + misson_teamskill = true, -- 编队支援技能和技能等级情况,json格式记录,{"teamskill1":1,"teamskill2":2,………..} + misson_teambond = true, -- 编队羁绊和羁绊等级,json格式记录,{"bondid1":1,"bondid2":2,………..} + }, + residence_reward = { --玩家挂机或排名奖励 --TODO + mission_threadid = true, --大关卡ID + mission_id = true, --关卡ID + mission_type = true, --关卡类型,见关卡类型枚举表 + residence_reward_type = true, --领取奖励方式,快速(超前领取)记录为1,正常领取记录为0 + residence_time = true, --挂机或排名时长 + residence_reward = true, --获得奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + }, + hero_rise = { --英雄觉醒 --TODO + hero_id = true, --英雄ID + hero_rise_cost = true, --英雄觉醒消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} + hero_rise_score = true, --英雄觉醒后评分提升 + hero_rise_result = true, --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} + }, + hero_upgrade = { --英雄升级 --TODO + hero_id = true, -- 英雄ID + hero_upgrade_cost = true, -- 英雄升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} + hero_upgrade_result = true, -- 英雄升级效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} + hero_upgrade_type = true, -- 英雄升级方式,连续升级:1,单击升级:0 + hero_upgrade_score = true, -- 英雄升级后评分 + hero_upgrade_scoreget = true, -- 通过英雄升级提升的评分 + }, + hero_break = { --英雄突破 --TODO + hero_id = true, -- 英雄ID + hero_break_cost = true, -- 英雄突破消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} + hero_break_result = true, -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} + hero_break_level = true, -- 英雄突破后等级上限 + }, + hero_talent = { --英雄天赋升级 --TODO + hero_id = true, -- 英雄ID + hero_talent_cost = true, -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} + hero_talent_levelbef = true, -- 英雄技能升级前等级 + hero_talent_level = true, -- 英雄技能升级后等级 + }, + hero_jewel = { --英雄铭文 --TODO + hero_id = true, -- 英雄ID + hero_jewel_sequence = true, -- 铭文装备编号,用以关联一次装备时产生的多条日志 + hero_jewel_id = true, -- 铭文ID + hero_jewel_part = true, -- 铭文装备部位 + hero_jewel_score = true, -- 铭文装备后的英雄分值 + hero_jewel_scorebefore = true, -- 铭文装备前的英雄分值 + hero_jewel_result = true, -- 铭文装备后效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} + }, + hero_note = { --英雄评价 --TODO + hero_id = true, -- 英雄ID + hero_note_action = true, -- 英雄评价界面操作,发布评论:0,点赞:1,反对:2 + hero_note_id = true, -- 操作的评价ID + hero_note_text = true, -- 操作的评价内容 + }, + hero_show = { --展示英雄 --TODO + hero_id = true, -- 英雄ID + }, + hero_recycle = { --英雄回收 + hero_recycle_list = true, -- 回收的英雄id列表,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + hero_recycle_reward = true, -- 回收后获得的奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + hero_recycle_cnt = true, -- 总回收英雄量 + }, + gacha = { --英雄招募 --TODO + gacha_id = true, -- 卡池ID + gacha_type = true, -- 卡池类型 + gacha_up = true, -- 卡池UP角色 + gacha_times = true, -- 抽卡次数 + gacha_reward = true, -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} + currency_type = true, -- 购买道具消耗的货币类型,记录货币ID + gacha_current = true, -- 购买道具消耗的货币数量 + gacha_cnt = true, -- 此卡池内的计数器 + }, + equip_wear = { --装备穿戴与卸载 --TODO + hero_id = true, --英雄ID + equip_id = true, --装备ID + equip_wear_action = true, --装备操作类型:装备:0,卸载:1 + equip_wear_part = true, --装备部位,记录部位ID + equip_wear_result = true, --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567} + equip_wear_change = true, --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45} + equip_wear_mode = true, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 + equip_wear_seqid = true, --自动穿戴时记录的系列ID,用以关联一次性装备时候产生的多条记录 + }, + equip_upgrade = { --装备升级 --TODO + hero_id = true, -- 英雄ID + equip_upgrade_part = true, -- 升级部位,记录部位ID + equip_id = true, -- 升级后的装备ID + equip_upgrade_amount = true, -- 升级获取的装备数量 + equip_upgrade_usedid = true, -- 升级消耗的装备ID + equip_upgrade_cost = true, -- 升级操作消耗装备数量 + equip_upgrade_currentid = true, -- 升级消耗的货币类型 + equip_upgrade_current = true, -- 升级操作消耗货币数量 + }, + carriage_dismantle = { --物资拆解 --TODO + item_id = true, -- 道具id + item_sequenceid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个礼包多个物品等情形 + item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表 + item_level = true, -- 道具等级 + item_number = true, -- 道具变化数量的绝对值 + carriage_dismantle_type = true, -- 拆解方式,时间到期:0,钥匙开启:1 + carriage_dismantle_time = true, -- 拆解耗时,填写实际耗时 + carriage_dismantle_cost = true, -- 拆解花费钥匙数量,未使用填写0 + carriage_dismantle_rwd = true, -- 拆解获得物资,json格式记录,{'itemid1':2,'itemid2':3,…………..} + }, + carriage_logistics = { --后勤室 --TODO + carriage_logistics_type = true, -- 后勤室制作类型ID,变异:0,通常:1,魔法:2 + carriage_logistics_itemid = true, -- 后勤室升级物品或技能ID + carriage_logistics_itemlv = true, -- 升级后物品或技能等级 + carriage_logistics_gear = true, -- 后勤室升级花费齿轮数量 + carriage_logistics_coin = true, -- 后勤室升级花费美食币数量 + }, + carriage_decals = { --贴纸拆解 --TODO + item_id = true, --道具id + item_sequenceid = "ucode", --道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个礼包多个物品等情形 + item_type = true, --道具类型,具体见枚举表中道具类型枚举表 + item_level = true, --道具等级 + item_number = true, --道具变化数量的绝对值 + carriage_decals_rwdid = true, --拆解获得物资ID + carriage_decals_rwdnum = true, --拆解获得物资数量 + }, + carriage_video = { --放映室 --TODO + carriage_video_type = true, --放映室类型,剧情CG:0, 角色CG:1, 主线剧情:2, 角色剧情:3, 活动剧情:4, 图鉴:5 + carriage_video_id = true, --放映室片段ID + carriage_video_coinid = true, --放映奖励货币类型,无奖励则填写0 + carriage_video_coinnum = true, --放映奖励货币数量,无奖励则填写0 + carriage_video_item = true, --放映奖励其他物品数量,json格式记录,{'itemid1':10,'itemid2':5,…………..},无奖励则填写0 + }, + carriage_cook = { --调理室 --TODO + item_id = true, -- 道具id + item_level = true, -- 道具等级 + item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表 + carriage_cook_amount = true, -- 制作总量 + carriage_cook_cost = true, -- 制作消耗道具,json格式记录,{'itemid1':10,'itemid2':5,…………..} + }, + activity = { --活动或指南奖励 --TODO + activity_id = true, -- 活动ID(或活动指定任务的ID) + activity_type = true, -- 活动类型,见活动类型枚举表 + activity_reward = true, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + }, + task_reward = { --任务奖励 --TODO + task_reward_id = true, --任务奖励ID + task_reward_type = true, --任务奖励类型,见 任务奖励类型枚举表 + task_reward_detail = true, --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + }, + shop_purchase = { --商店购买行为 --TODO + item_id = true, -- 道具id + item_sequenceid = "ucode", -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一个购买礼包多个物品等情形 + item_type = true, -- 道具类型,具体见枚举表中道具类型枚举表 + item_level = true, -- 道具等级 + item_cnt = true, -- 购买数量技术 + currency_type = true, -- 购买道具消耗的货币类型,记录货币ID + shop_purchase_current = true, -- 购买道具消耗的货币数量 + shop_id = true, -- 商店ID + }, + friend_opt = { --好友操作 --TODO + friend_opt_type = true, -- 好友操作类型,见枚举表中 好友操作类型枚举表 + friend_accountid = true, -- 好友账户id + friend_roleid = true, -- 好友账户下的角色id + friend_cnt = true, -- 操作后好友数量 + }, + friend_list = { --好友列表 --TODO + friend_accountid = true, --好友账户id + friend_roleid = true, --好友账户下的角色id + }, + friend_black = { --黑名单列表 --TODO + friend_accountid = true, -- 好友账户id + friend_roleid = true, -- 好友账户下的角色id + }, + communication = { --玩家发言 --TODO + publish_type = true, --发言类型,全部:0,公告:1,世界:2,联盟:3,私聊:4 + publish_status = true, --发送状态,发送成功:0,发送失败:1,被屏蔽:2,其他:3 + publish_receive_accid = true, --接收者账户ID + publish_receive_roleid = true, --接收者角色ID + publish_text = true, --发言内容 + }, + restaurant_up = { --摊位升级 --TODO + restaurant_up_type = true, --升级部件类型,店面:0, 接客:1, 满意度:2, 宣传:3, 广告:4, 周边:5 + restaurant_up_gear = true, --消耗齿轮数量 + restaurant_up_coin = true, --花费美食币数量 + restaurant_up_effectbef = true, --升级前加成 + restaurant_up_effect = true, --升级后加成 + }, + restaurant_sale = { --摊位售卖 --TODO + item_id = true, -- 售卖物品ID + restaurant_sale_seat = true, -- 售卖物品所在位置 + restaurant_sale_time = true, -- 售卖时长 + restaurant_sale_type = true, -- 售卖方式,正常售卖:0, 加速:1,移除售卖:2 + restaurant_sale_coin = true, -- 售卖获得美食币 + restaurant_sale_gear = true, -- 售卖获得齿轮 + }, + restaurant_material = { --食材获取 --TODO + item_id = true, -- 获取物品ID + restaurant_material_seqid = true, -- 道具变动关联ID,用于关联一次动作产生多条不同类型的日志,如一次获取两件道具情况 + restaurant_material_start = true, -- 申请获取时间 + restaurant_material_time = true, -- 申请到领取耗时 + restaurant_material_num = true, -- 获取物品数量 + }, + restaurant_order = { --订单任务 --TODO + restaurant_order_id = true, -- 订单任务ID + restaurant_order_status = true, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 + restaurant_order_start = true, -- 订单接收时间,timestamp格式记录 + restaurant_order_rwd = true, -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} + restaurant_order_lv = true, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 + }, + restaurant_collect = { --餐厅顾客图谱 --TODO + restaurant_collect_id = true, -- 图谱收集ID + restaurant_collect_rwd = true, -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} + restaurant_collect_plan = true, -- 收集进度,即解锁顾客,数字表示 + }, + achievement = { --成就达成 --TODO + achievement_id = true, -- 成就id + achievement_type = true, -- 成就类型,具体枚举表中成就类型枚举表 + achievement_name = true, -- 成就名称 + achievement_score = true, -- 领取成就后成就点数 + achievement_subscore = true, -- 领取成就后小类成就点数 + achievement_reward = true, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} + }, + get_gift = { --礼包兑换 --TODO + gift_id = true, -- 礼包ID + gift_key = true, -- 礼包key + gift_reward = true, -- 礼包奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} + gift_name = true, -- 礼包名称 + gift_reason = true, -- 礼包发放原因,见发放原因枚举表 + }, } -local function printError(info) - print(info) - print(debug.traceback()) +local function isIos(self) + local sid = self:getProperty("sid") + return sid == 2 end -local function checkType(logType, field, value, ctype) - local typecheckfunc = { - keyword = function() - --长度不超过256 - if type(value) ~= "string" then - value = tostring(value) - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [keyword], value : %s", logType, field, value)) - else - if #value > 256 then - printError(string.format("LOG ERROR: logType [%s] field [%s] [keyword] type to long. value : %s", logType, field, value)) - end - end - return value - end, - text = function() - if type(value) ~= "string" then - value = tostring(value) - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [text], value : %s", logType, field, value)) - end - return value - end, - integer = function() - if type(value) ~= "number" then - value = tonumber(value) - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], value : %s", logType, field, value)) - end - if value then - if math.type(value) ~= "integer" then - local oldValue = value - value = math.floor(value) - if value ~= oldValue then - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], is float, value : %s", logType, field, value)) - end - end - if -2147483648 > value or value > 2147483647 then - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [integer], too big, value : %s", logType, field, value)) - value = nil - end - end - return value - end, - short = function() - if type(value) ~= "number" then - value = tonumber(value) - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], value : %s", logType, field, value)) - end - if value then - if math.type(value) ~= "integer" then - local oldValue = value - value = math.floor(value) - if value ~= oldValue then - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], is float, value : %s", logType, field, value)) - end - end - - if -32768 > value or value > 32768 then - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [short], too big, value : %s", logType, field, value)) - value = nil - end - end - return value - end, - long = function() - if type(value) ~= "number" then - value = tonumber(value) - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], value : %s", logType, field, value)) - end - if value then - if math.type(value) ~= "integer" then - local oldValue = value - value = math.floor(value) - if type(value) ~= "integer" then - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], too big, value : %s", logType, field, value)) - value = nil - elseif value ~= oldValue then - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [long], is float, value : %s", logType, field, value)) - end - end - end - return value - end, - float = function() - if type(value) ~= "number" then - value = tonumber(value) - printError(string.format("LOG ERROR: logType [%s] field [%s] isn't [float], value : %s", logType, field, value)) - end - return value - end, +local appid, sdkId +local function getBaseLog(self) + local uid = self:getProperty("uid") + if not appid then + appid, sdkId = string.match(uid, "(.*)_(.*)") + if not appid then + sdkId = uid + appid = 0 + end + end + local log = { + server_id = server_id, + timestamp = skynet.timex(), + app_id = appid, + plat_id = isIos(self) and 0 or 1, + sdk_uid = sdkId, + account_id = uid, + role_id = self:getProperty("id"), + role_name = self:getProperty("name"), + level = self:getProperty("level"), + vip = 0, + device_id = self:getProperty("device"), + device_model = self:getProperty("dmode"), + version = "v2.0.1", + client_version = self.clientVersion or "1.0.0", + sys_version = self.sysVersion or "unknow", + ip = self.ip or "0.0.0.0", + network = self.network or "unknow", + record_date = os.date("%Y%m%d"), } + return log +end - if typecheckfunc[ctype] then - return typecheckfunc[ctype]() - else - printError(string.format("LOG ERROR: logType [%s] field [%s] have a new type [%s] need add check.", logType, field, ctype)) - return nil - end +local function printError(info) + print(info) + print(debug.traceback()) end local RoleLog = {} function RoleLog.bind(Role) - function Role:log(logType, contents) + + function Role:log() + end + + function Role:log_new(logType, contents) contents = contents or {} - local _logType = LogType[logType] - if not _logType then - printError(string.format("LOG ERROR: new logType [%s] need Add Maping.", logType)) + local schema = MethodType[logType] + if not schema then + printError(string.format("LOG ERROR: new logType [%s].", logType)) return end - local doc = {} - for field, ctype in pairs(commonRoleField) do - if contents[field] then - printError(string.format("LOG ERROR: logType [%s] had field [%s] overwrite default.", logType, field)) - end - doc[field] = checkType("commonRoleField", field, self:getProperty(field), ctype) - end + local doc = getBaseLog(self) - local mapping = Mapping[_logType] - if mapping["ucode"] and not contents["ucode"] then - contents["ucode"] = self:getActionUcode() + doc["method"] = logType + for field, value in pairs(contents) do + if not schema[ftype] then + printError(string.format("LOG ERROR: logType [%s] have new field [%s], call yunying.", logType, field)) + end end - for field, value in pairs(contents) do - local ftype = mapping[field] - if ftype then - doc[field] = checkType(logType, field, value, ftype) - else - printError(string.format("LOG ERROR: logType [%s] have new field [%s] no type in mapping.", logType, field)) + for field, tag in pairs(schema) do + if not contents[field] then + if tag == "ucode" then + contents[field] = self:getActionUcode() + else + printError(string.format("LOG ERROR: logType [%s] lose field [%s].", logType, field)) + end end end if not logd then return end - pcall(skynet.send, logd, "lua", "log", logType, doc, _logType) + pcall(skynet.send, logd, "lua", "log", doc) end + function Role:startActionUcode() if not self._uniqueCount then self._uniqueCount = 0 @@ -225,7 +508,8 @@ function RoleLog.bind(Role) function Role:getActionUcode() return self._actionUcode - end + end + end return RoleLog \ No newline at end of file diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 8516034..889bc14 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -207,6 +207,7 @@ function RolePlugin.bind(Role) function Role:addPlayExp(addExp, params) local level = self:getProperty("level") + local oldLevel = level if not csvdb["player_expCsv"][level + 1] then return end @@ -222,20 +223,13 @@ function RolePlugin.bind(Role) newExp = csvdb["player_expCsv"][level].exp - 1 -- 没有下一级了 经验溢出太多 扣除 end end - - if params.log then - local log = clone(params.log) - if log["cint1"] or log["cint2"] then - print("addPlayExp error log have cint1 or cint2 or cint3", debug.traceback()) - end - - log["cint1"] = addExp - log["cint2"] = newExp - log["cint3"] = level - - self:log("player_exp", log) - else - print("addPlayExp no log ", debug.traceback()) + if level > oldLevel then + self:log("setLevel", { + level_before = oldLevel, + level_changemain = params.level_changemain, + level_changedetail = 0, + level_reward = "{}", + }) end self:updateProperties({level = level, exp = newExp}) @@ -1511,8 +1505,8 @@ function RolePlugin.bind(Role) SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" })) return end - - local rechargeData = csvdb["shop_rechargeCsv"][orderObject:getProperty("rechargeId")] + local rechargeId = orderObject:getProperty("rechargeId") + local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] if rechargeData.rmb ~= tonumber(params.amount) then skynet.error(string.format("fake order: %s, roleId: %d, order: %s, rmb %s, get %s", params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount @@ -1520,16 +1514,34 @@ function RolePlugin.bind(Role) return end - local reward = self:recharge({ - id = orderObject:getProperty("rechargeId"), - transactionId = params.transactionId, - pay_time = params.pay_time, - order = partnerOrderStr + local order_type = self.getProperty("rmbC") > 0 and 0 or 1 + local status, reward = self:recharge({ + id = rechargeId }) orderObject:setProperty("finishTime", skynet.time()) orderObject:setProperty("status", "finish") redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr) + + if not status then + status = 200 + else + status = 1000 + status + end + role:log("setOrder", { + order_status = status, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他" + item_id = rechargeId, -- 道具id + item_type = rechargeData.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表 + item_name = rechargeData.title, -- 购买的道具名 + item_number = 1, -- 购买的道具数量 + item_level = 1, -- 购买的道具等级 + order_cost = rechargeData.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee' + order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范 + order_type = order_type, -- 订单类型,首充记录为1,否则为0 + order_id = params.transactionId, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no' + }) + if status ~= 200 then return end + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr, result = "success", reward = reward})) @@ -1542,11 +1554,11 @@ function RolePlugin.bind(Role) local rechargeData = csvdb["shop_rechargeCsv"][id] if not rechargeData then skynet.error("recharge id not exist", id) - return + return 1 end if not self.storeData:checkRechargeRecord(rechargeData.limit, id) then - return 1 + return 2 end local diamondCount = 0 @@ -1561,13 +1573,13 @@ function RolePlugin.bind(Role) end self:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}}) elseif rechargeData.shop == 2 then --通行证商店 - reward, _ = self:award(rechargeData.itemFirst, {log = {desc = "recharge", int1 = id}}) + reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) self.storeData:onBuyCard(rechargeData.type, rechargeData.time) elseif rechargeData.shop == 3 then -- 礼包商店 - reward, _ = self:award(rechargeData.itemFirst, {log = {desc = "recharge", int1 = id}}) + reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) else skynet.error("invalid recharge shop type " .. id) - return + return 3 end if diamondCount > 0 then @@ -1577,10 +1589,8 @@ function RolePlugin.bind(Role) -- 累充 local rmb = rechargeData.rmb self:updateProperty({field = "rmbC", delta = rmb}) - - self:log("role_action", {desc = "recharge", int1 = id, int2 = rmb, key1 = params.transactionId, key2 = params.order, long1 = params.pay_time}) - return reward + return nil, reward end --直接给玩家发送邮件,立即推送小红点 diff --git a/src/services/agent_ctrl.lua b/src/services/agent_ctrl.lua index 8406ab5..ec26a98 100644 --- a/src/services/agent_ctrl.lua +++ b/src/services/agent_ctrl.lua @@ -128,7 +128,7 @@ function _M:check_agent_status() next_log_time = now + 60 local count = table_nums(self.u2f) datacenter.set("onlineCount", count) - pcall(skynet.send, logd, "lua", "log", "online", {count = count}, "online") + -- pcall(skynet.send, logd, "lua", "log", "online", {count = count}, "online") end end diff --git a/src/services/logd.lua b/src/services/logd.lua index 672f64d..54b969e 100644 --- a/src/services/logd.lua +++ b/src/services/logd.lua @@ -55,38 +55,11 @@ skynet.register_protocol { end } - - --- 日志 index 不包含 日期的 index_suffix -local IndexNoDate = { - online = true, -} --- 不走 role log 的日志都要自行注意 mapping 设置【重要】 --- index_suffix index 后缀 默认为 common -function CMD.log(logType, doc, index_suffix) - index_suffix = index_suffix or "common" - if index_suffix == "common" then - doc["@type"] = logType - else - if logType ~= index_suffix then -- 定制后缀 不一定有type 不相等时才有type - doc["@type"] = logType - end - end - - local now = skynet.timex() - doc["timestamp"] = now - doc["timestamp_f"] = os.date("%Y-%m-%d %H:%M:%S", now) - doc["server"] = serverId - - -- 自己加好 index - if IndexNoDate[index_suffix] then - doc["@index"] = string.format("gamelog-%s", index_suffix) - else - doc["@index"] = string.format("gamelog-%s-%s", os.date("%Y%m%d", now), index_suffix) - end +function CMD.log(doc) if not socketdriver.send(log_fd, json.encode(doc) .. "\n") then if not connecting then CMD.open() -- 连一下试试 + socketdriver.send(log_fd, json.encode(doc) .. "\n") end end end -- libgit2 0.21.2