소스 검색

增加日志输出

neo 1 년 전
부모
커밋
1be0c28b64
3개의 변경된 파일18개의 추가작업 그리고 9개의 파일을 삭제
  1. 9 4
      dev/base/baseModule.lua
  2. 9 4
      nodes/login/controllers/usr.lua
  3. 0 1
      nodes/login/lib/webapp.lua

+ 9 - 4
dev/base/baseModule.lua

@@ -44,6 +44,10 @@ function root:get_module_redis_key()
44 44
     local moduleKey = string.format("mdl:%s:%s", self.mdlName, tostring(self:getKeyValue()))
45 45
     return moduleKey
46 46
 end
47
+-- 模块数据库表名
48
+function root:get_table_name()
49
+    return string.format("mdl_%s", tostring(self.mdlName))
50
+end
47 51
 
48 52
 -- 获取玩家模块数据
49 53
 function root:get_data_from_db()
@@ -54,8 +58,9 @@ function root:get_data_from_db()
54 58
     end
55 59
 
56 60
     if self.isSaveDB then
57
-        local sql = sqlUtil.select_table_by_key(self.mdlName, self.keyName, self:getKeyValue())
61
+        local sql = sqlUtil.select_table_by_key(self:get_table_name(), self.keyName, self:getKeyValue())
58 62
         res = lib_game_mysql:query(sql)
63
+        log.info("get_data_from_db sql[%s] res[%s]", tostring(sql), tostring(res))
59 64
         if res and res[1] then
60 65
             -- add to redis
61 66
             redisUtil.hmset(moduleKey, res[1])
@@ -83,7 +88,7 @@ function root:get_column_db_value(column)
83 88
     if is_empty(column) then
84 89
         return
85 90
     end
86
-    local key = string.format("mdl:%s:%s", tostring(self.mdlName), tostring(self.uid))
91
+    local key = self:get_module_redis_key()
87 92
     local val = lib_game_redis:hget(key, column)
88 93
     if self:is_json(column) then
89 94
         val = string.format("'%s'", cjson_encode(val))
@@ -108,10 +113,10 @@ function root:backup_to_db()
108 113
         table.include(values, self:get_column_db_value(k))
109 114
     end
110 115
 
111
-    local tbName = string.format("mdl_%s", tostring(self.mdlName))
116
+    local tbName = self:get_table_name()
112 117
     local sql =
113 118
         string.format("replace into %s (%s) value (%s);", tbName, table.concat(colums, ","), table.concat(values, ","))
114
-    lib_game_mysql:query(sql)
119
+    return lib_game_mysql:query(sql)
115 120
 end
116 121
 -- 删除模块热数据
117 122
 function root:del_hot_data()

+ 9 - 4
nodes/login/controllers/usr.lua

@@ -153,11 +153,16 @@ function root.usr_register_by_phone(msg)
153 153
         return root.usr_login_by_phone(msg)
154 154
     end
155 155
     local uid = util_global:gen_user_id()
156
+    log.info("usr_register_by_phone account[%s] uid[%s]", tostring(account), tostring(uid))
156 157
     -- 注册账号
157
-    moduleData:hset(account, "account", "account", account)
158
-    moduleData:hset(account, "account", "password", password)
159
-    moduleData:hset(account, "account", "uid", uid)
160
-    accountObj:backup_to_db()
158
+    local err = moduleData:hset(account, "account", "account", account)
159
+    log.info("usr_register_by_phone account[%s] err[%s]", tostring(account), tostring(err))
160
+    err = moduleData:hset(account, "account", "password", password)
161
+    log.info("usr_register_by_phone password[%s] err[%s]", tostring(password), tostring(err))
162
+    err = moduleData:hset(account, "account", "uid", uid)
163
+    log.info("usr_register_by_phone uid[%s] err[%s]", tostring(uid), tostring(err))
164
+    err = accountObj:backup_to_db()
165
+    log.info("usr_register_by_phone backup_to_db err[%s]", tostring(err))
161 166
 
162 167
     -- 正常注册
163 168
     userData:user_init_register_info(uid, msg)

+ 0 - 1
nodes/login/lib/webapp.lua

@@ -306,7 +306,6 @@ function root:init()
306 306
 	local files = lfsUtil:get_path_lua_files("nodes/login/controllers")
307 307
 	for _, v in ipairs(files) do
308 308
 		controllerList[v] = require("controllers." .. v)
309
-		log.info("webapp init %s", tostring(v))
310 309
 	end
311 310
 end
312 311
 -- 热更新