浏览代码

修复埋点日志

neo 1 年之前
父节点
当前提交
fde5f6ce98
共有 2 个文件被更改,包括 18 次插入15 次删除
  1. 2 1
      common/service/statisticLogSrv.lua
  2. 16 14
      common/utils/serverLogUtil.lua

+ 2 - 1
common/service/statisticLogSrv.lua

@@ -68,7 +68,8 @@ end
68 68
 
69 69
 local root = {}
70 70
 
71
-function root.add_file_log(filename, dataStr)
71
+function root.add_file_log(key, date, dataStr)
72
+    local filename = string.format("%s-%s", key, date)
72 73
     table.insert(logQueue, {filename = filename, dataStr = dataStr})
73 74
     l_sync_log_data()
74 75
 end

+ 16 - 14
common/utils/serverLogUtil.lua

@@ -8,7 +8,7 @@ local root = {}
8 8
 local function writeServerLog(key, date, data)
9 9
     assert(key and date)
10 10
     local file = string.format("%s-%s", key, date)
11
-    skynet.send("statisticLog", "lua", "add_file_log", file, data)
11
+    skynet.send("statisticLog", "lua", "add_file_log", key, date, data)
12 12
 end
13 13
 
14 14
 function root.getActiveKey(date)
@@ -57,20 +57,22 @@ function root.logResource(uid, eventId, itemId, resChgs, resResult, channel, ban
57 57
     local now = timeUtil.currentTime()
58 58
     local date = timeUtil.toDate(now)
59 59
     local dateStr = timeUtil.toString(now)
60
-    local data = {
61
-        date,
62
-        dateStr,
63
-        uid,
64
-        bandShareCode,
65
-        channel,
66
-        eventId,
67
-        itemId,
68
-        resChgs or 0,
69
-        resResult or 0
70
-    }
71
-    local dataStr = root.formatData(data)
72 60
 
73
-    writeServerLog("resource", date, dataStr)
61
+    local cnt =
62
+        string.format(
63
+        "%s;%s;%s;%s;%s;%s;%s;%s;%s;",
64
+        tostring(date),
65
+        tostring(dateStr),
66
+        tostring(uid),
67
+        tostring(bandShareCode or ""),
68
+        tostring(channel),
69
+        tostring(eventId),
70
+        tostring(itemId),
71
+        tostring(resChgs or 0),
72
+        tostring(resResult or 0)
73
+    )
74
+
75
+    writeServerLog("resource", date, cnt)
74 76
 end
75 77
 
76 78
 -- 服务端注册埋点