| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SBLogger
- {
- private static bool debug = false;
- private string tag;
- public SBLogger(string tag)
- {
- this.tag = "[" + tag + "]";
- }
- public void Log(object info)
- {
- if (!debug) return;
- JCUnityLib.CoroutineStarter.Start(SendToServer(0, info));
- }
- public void Warn(object info)
- {
- if (!debug) return;
- JCUnityLib.CoroutineStarter.Start(SendToServer(1, info));
- }
- public void Error(object info)
- {
- if (!debug) return;
- JCUnityLib.CoroutineStarter.Start(SendToServer(2, info));
- }
- IEnumerator SendToServer(int level, object info)
- {
- long time = JCUnityLib.TimeUtils.GetTimestamp();
- string txt = this.tag + " " + info;
- yield return null;
- if (level == 0) Debug.Log(txt);
- else if (level == 1) Debug.LogWarning(txt);
- else if (level == 2) Debug.LogError(txt);
- int uid = LoginMgr.myUserInfo.id;
- if (uid > 0) {
- UserPlayer.ins?.call("sbLog", uid, time, tag, info.ToString());
- }
- }
- }
|