Unity 自定義日誌儲存

2021-10-02 21:02:27 字數 896 閱讀 5467

**: 

using unityengine;

using system.io;

using system;

using system.diagnostics;

using debug = unityengine.debug;

public class debugtrace

}return m_instance;}}

#endregion

private debugtrace()

///

/// 開啟跟蹤日誌資訊

///

/// 是否記錄日誌

/// 是否顯示所有堆疊幀 預設只顯示當前幀 如果設為0 則顯示所有幀

/// 過濾 預設log級別以上

/// 是否在編輯器中產生日誌記錄 預設不需要

public void setlogoptions(bool logenable, int showframs = 1, logtype filterlogtype = logtype.log, bool editorcreate = false)

}關於 filterlogtype

filterlogtype預設設定是log,會顯示所有型別的log。

warning:會顯示warning,assert,error,exception

assert:會顯示assert,error,exception

error:顯示error和exception

exception:只會顯示exception

使用:在打包發布後某些資料會獲取不到 例如行號 參考:

最後看下效果:

不足:發布版本 出現異常捕捉不到 行號獲取不到

debug版本可以勾選developmend build 捕捉到更多資訊

unity 日誌級別 Unity 自定義日誌儲存

using unityengine using system.io using system using system.diagnostics using debug unityengine.debug public class debugtrace private filestream files...

自定義日誌工具

import android.util.log created by xiongxl on 2017 2 20.public class logutil public static void d string tag,string msg public static void i string ta...

自定義日誌檔案

借用 部落格 usr bin python coding utf 8 importlogging importos.path importtime 自定義日誌類 classlogger object def init self,logger 指定儲存日誌的檔案路徑,日誌級別,以及呼叫檔案 將日誌存入...