unity 日志级别_【Unity】通用的Debugger日志模块

本文介绍了一个在Unity中实现的自定义Debugger日志模块,该模块提供了控制日志启用、时间戳、保存到文件以及堆栈跟踪的功能。用户可以开关不同级别的日志输出,包括普通、错误和警告,并且可以选择是否将日志写入到指定目录的文件中,便于后期查看和分析。
摘要由CSDN通过智能技术生成

usingSystem;usingSystem.IO;namespaceUnityEngine

{///

///系统日志模块///

public classDebugger

{public static bool EnableLog; //是否启用日志,仅可控制普通级别的日志的启用与关闭,LogError和LogWarn都是始终启用的。

public static bool EnableTime = true;public static bool EnableSave = false; //是否允许保存日志,即把日志写入到文件中

public static bool EnableStack = false;public static string LogFileDir = Application.persistentDataPath + "/DebuggerLog/";public static string LogFileName = "";public static string Prefix = ">"; //用于与Unity默认的系统日志做区分。本日志系统输出的日志头部都会带上这个标记。

public static StreamWriter LogFileWriter = null;public static boolUseUnityEngine;private static string GetLogText(string tag, stringmessage)

{string str = "";if(EnableTime)

{

str= DateTime.Now.ToString("HH:mm:ss.fff") + " ";

}return (

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值