local lua_log = _G.lua_log
local LogDefine = require("common.LogDefine")


--日志中的 uuid 由原来的 account 改为 newUniqueTag
function init()
    if has_init then
        return
    end
    has_init = true
    --[[服务器测试输出--]] LOGID_TEST = lua_log.reg("log/test", "", 0)
    --[[服务器测试输出--]] LOGID_DEBUG = lua_log.reg("log/debug", "", 0)
    --[[服务器输出跟踪日志--]] LOGID_OSS_BT = lua_log.reg("log/err_bt", "", 0)
    --[[所有的pcall失败报错输出]] LOGID_ERR_PCALL = lua_log.reg("log/err_pcall", "", 0)
    --[[服务器obj数据统计--]] LOGID_MONITOR = lua_log.reg("log/monitor", "thread,luamem,scene,obj,monster,human,pet", 0)
    --[[GM指令--]] LOGID_OSS_GM_CODE = lua_log.reg("log/oss_gm_code", "uuid,account_name,role_name,cmd,arg", 0)
    --[[INNER_close]] LOGID_INNER_CLOSE = lua_log.reg("log/inner_close", "", 0)

    --[[客户端报错收集--]] LOGID_OSS_CLIENT_ERR = lua_log.reg("log/oss_client_err", "uuid,account_name,role_name,err", 300)
    --[[客户端资源加载报错收集--]] LOGID_OSS_CLIENT_LOAD_ERR = lua_log.reg("log/oss_client_load_err", "uuid,account_name,role_name,err", 300)

    --[[创建流失率--]] LOGID_OSS_CREATELOSS = lua_log.reg("log/oss_create_loss", "account_name,role_name,step,ip,pf,appid,appid2", 300)
    --[[注册]] LOGID_OSS_REGISTER = lua_log.reg("log/oss_register", "uuid,account_name,role_name,ip,pf,appid,cnt", 300)
    --[[登录--]] LOGID_OSS_LOGIN = lua_log.reg("log/oss_login", "uuid,account_name,role_name,level,ip", 300)
    --[[登出--]] LOGID_OSS_LOGOUT = lua_log.reg("log/oss_logout", "uuid,account_name,role_name,level,ip,reason,online_time", 300)
    --[[主指引完成--]] LOGID_OSS_GUIDE_MAIN = lua_log.reg("log/oss_guide_main", "uuid,account_name,role_name,level,ip,pf,appid,main_id,skip_type", 300)
    --[[子指引完成--]] LOGID_OSS_GUIDE_SUB = lua_log.reg("log/oss_guide_sub", "uuid,account_name,role_name,level,ip,pf,appid,sub_id", 300)

    --[[聊天--]] LOGID_OSS_CHAT = lua_log.reg("log/oss_chat", "uuid, account_name, role_name, ip, channel, content", 300)
    --[[升级--]] LOGID_OSS_LEVELUP = lua_log.reg("log/oss_level_up", "uuid,account_name,role_name,prev_level,level", 300)
    --[[守护之龙--]] LOGID_OSS_DRAGON_LEVEL = lua_log.reg("log/oss_dragon_lv", "uuid,account_name,role_name,level,skill_level", 300)
    --[[公会科技]] LOGID_OSS_UNION_TECH = lua_log.reg("log/oss_unionTech_lv", "uuid,account_name,role_name,type,level", 300)
    --[[金币流通--]] LOGID_OSS_JINBI = lua_log.reg("log/oss_money", "uuid,account_name,role_name,level,money,type,item_id,num,remain_money", 300)
    --[[钻石流通--]] LOGID_OSS_GOLD = lua_log.reg("log/oss_gold", "uuid,account_name,role_name,level,gold,type,item_id,num,remain_gold", 300)
    --[[友情值流通]] LOGID_OSS_FRIENDHEART = lua_log.reg("log/oss_friendheart", "uuid,account_name,role_name,level,friendheart,type,item_id,num,remain_friendheart", 300)
    --[[道具流通--]] LOGID_OSS_ITEM = lua_log.reg("log/oss_item", "uuid,account_name,role_name,level,type,item_id,num,afterCount", 300)
    --[[英雄流通--]] LOGID_OSS_HERO = lua_log.reg("log/oss_hero", "uuid,account_name,role_name,level,type,hero_id,num,hero_uuid, star", 300)
    --[[符文流通--]] LOGID_OSS_FUWEN = lua_log.reg("log/oss_fuwen", "uuid,account_name,role_name,level,type,fuwen_id,num", 300)
    --[[装备流通--]] LOGID_OSS_EQUIP = lua_log.reg("log/oss_equip", "uuid,account_name,role_name,level,type,equip_id,num, equip_uuid", 300)
    --[[召唤法阵--]] LOGID_OSS_DRAWCARD = lua_log.reg( "log/oss_drawcard", "uuid,account_name,role_name,level,type,hero_ids,item_id,num,zuanshi,jifen", 300)
    --[[战斗过程详细日志--]] LOGID_FIGHT_LOG = lua_log.reg("log/fight_log", "", 0)
    --[[充值--]] LOGID_OSS_PAY = lua_log.reg("log/oss_pay", "uuid, account_name,role_name,level, billno, buyID, money, gold, online,region", 300)
    --[[充值错误--]] LOGID_OSS_PAY_ERR =lua_log.reg("log/oss_pay_err", "account_name,result,billno, buyID, money, gold,region", 300)
    --[[腾讯购买--]] LOGID_OSS_TENCENT_BUY = lua_log.reg("log/oss_tencent_buy", "uuid,account_name,role_name,logintype,openid,openkey,pf,yuanbao,buyID", 300)

    --[[跨服相关调试日志--]] LOGID_MIDDLE_BT = lua_log.reg("log/err_middle_bt", "err", 0)

    --[[怪物死亡]] LOGID_OSS_MONSTER =lua_log.reg("log/oss_die", "uuid,account_name,role_name,level,kill_id,name,map_id", 300)
    --[[金币挑战]] LOGID_OSS_BATTLE_GOLD = lua_log.reg("log/oss_jbtz_lv", "uuid,account_name,role_name,lv", 300)
    --[[经验挑战]] LOGID_OSS_BATTLE_EXP = lua_log.reg("log/oss_exptz_lv", "uuid,account_name,role_name,lv", 300)
    --[[英雄挑战]] LOGID_OSS_BATTLE_HERO = lua_log.reg("log/oss_yxtz_lv", "uuid,account_name,role_name,lv", 300)
    --[[黄金龙穴]] LOGID_OSS_BATTLE_DRAGON = lua_log.reg("log/oss_hjlx_lv", "uuid,account_name,role_name,lv", 300)
    --[[水晶之地]] LOGID_OSS_BATTLE_CRYSTAL = lua_log.reg("log/oss_sjzd_lv", "uuid,account_name,role_name,lv", 300)
    --[[灵兽深渊]] LOGID_OSS_BATTLE_MOSHOU = lua_log.reg("log/oss_mssz_lv", "uuid,account_name,role_name,lv", 300)

    --[[主线关卡]] LOGID_OSS_BATTLE_MAINGATE = lua_log.reg("log/oss_maingate_lv", "uuid,account_name,role_name,lv", 300)
    --[[恶魔之塔]] LOGID_OSS_BATTLE_DEMONTOWER = lua_log.reg("log/oss_demonTower_lv", "uuid,account_name,role_name,lv", 300)
    --[[绝望深渊]] LOGID_OSS_BATTLE_DESPAIRABYSS = lua_log.reg("log/oss_despairAbyss_lv", "uuid,account_name,role_name,lv", 300)
    --[[遗迹探险]] LOGID_OSS_BATTLE_RELIC = lua_log.reg("log/oss_relic_lv", "uuid,account_name,role_name,lv", 300)

    --[[分享日志]] LOGID_OSS_SHARE = lua_log.reg("log/oss_share", "uuid, account_name, role_name, pf, appid, way", 300)
    --[[online 0：离线，保存db，未发货1：在线发货 2：离线期间请求，上线后发货发货--]] 
      LOGID_OSS_DELIVER = lua_log.reg("log/oss_deliver", "uuid, account_name,role_name,level, billno,money, type, itemId,cnt, online,region",300)
    --[[英雄起源活动领取日志]] LOGID_OSS_PAYREWARD = lua_log.reg("log/oss_payreward", "uuid,account_name,role_name,week,type,gift_index", 300)
    --[[英雄升级日志]] LOGID_OSS_HEROLVUP = lua_log.reg("log/oss_herolvup", "uuid,account_name,role_name,rerouuid,oldlv,newlv", 300)
    --[[遗迹探险插入DB]] LOGID_OSS_YJTX_DB = lua_log.reg("log/oss_yjtx_db", "",0)
    --[[竟技场-王者争霸]] LOGID_JJC_GODWAR = lua_log.reg("log/jjc_godwar","",0)
    --[[开服活动]] LOGID_OSS_OPENSERVER_ACT = lua_log.reg("log/oss_openserver_act","",300)
    --[[周循环活动]] LOGID_OSS_WEEKLOOP_ACT = lua_log.reg("log/week_loop_act","",300)
    --[[代金券]] LOGID_OSS_VOUCHERSHOP = lua_log.reg("log/vouchershop","",300)
    --[[埋点]] LOGID_OSS_MAIDIAN = lua_log.reg("log/oss_maidian","",300)
    --[[通用日志]] LOGID_OSS_COMMON = lua_log.reg("log/oss_common","",300)
    --[[合服日志]] LOGID_OSS_MERGE = lua_log.reg("log/oss_merge","",300)
    --[[通用活动日志]] LOGID_OSS_COMMON_ACT = lua_log.reg("log/oss_actcommon","",300)   -- 用于各种活动开启，结束等日志
    --[[渠道返利日志]] LOGID_OSS_REBATE = lua_log.reg("log/oss_rebate","",300)   -- 用于各种活动开启，结束等日志
    --[[天梯赛]] LOGID_OSS_JJCNEWLADDER = lua_log.reg("log/oss_jjcladder","",300)   -- 天梯赛日志
    --[[月光宝盒]] LOGID_OSS_STORAGEBOx = lua_log.reg("log/oss_storageBox","",300)   -- 月光宝盒
    --[[诸神圣域-战斗]] LOGID_OSS_GODSAREA_CHALLENGE = lua_log.reg("log/oss_godArea_challenge","",300)
    --[[诸神圣域-邮件]] LOGID_OSS_GODSAREA_MAIL = lua_log.reg("log/oss_godArea_mail","",300)

    --[[战区争霸-战斗]] LOGID_OSS_AREABATTLE_BATTLE = lua_log.reg("log/oss_areaBattle_battle","",300)
    --[[战区争霸-奖励]] LOGID_OSS_AREABATTLE_AWARD = lua_log.reg("log/oss_areaBattle_award","",300)

    --[[异界之战日志]] LOGID_OSS_ANOTHERWORLDBATTLE = lua_log.reg("log/oss_anotherWorldBattle", "", 300)
    --[[百战成神]] LOGID_OSS_BZCS = lua_log.reg("log/oss_bzcs", "", 300)

end
init()

write = lua_log.write

function writeItemLog(human, grid, count, logType, index)
    local logTypeID = LogDefine.DEFINE[logType] + LogDefine.TYPE["item"]
    write(
        LOGID_OSS_ITEM,
        human.db._id,
        human.db.account,
        human.db.name,
        human.db.lv,
        logTypeID,
        grid.id,
        count,
        index or 0
    )
end

function qqInfo(human)
    return human.vopenid or 0, 0, 0, human.phpChanelID or "", 0
end

function writeShareLog(human, shareType)
    --'1:微信好友分享,2:微信朋友圈,3:微博,4:QQ,5:QQ好友,6:其他'
    write(LOGID_OSS_SHARE, human.db._id, human.db.account, human.db.name, human.pf, human.appid, shareType)
end
