flutter 日誌工具類

class LogUtils {
//環境標識位 Release爲true debug 爲false
static const bool isRelease = const bool.fromEnvironment("dart.vm.product"); static void d(String tag, Object message) { if (!isRelease) _printLog(tag, 'D -> ', message); } static void i(String tag, Object message) { _printLog(tag, 'I -> ', message); } static void e(String tag, Object message, {Exception e}) { _printLog(tag, 'E -> ', message); } static void _printLog(String tag, String level, Object message) { StringBuffer sb = new StringBuffer(); sb..write(level)..write(tag ?? '')..write(': ')..write(message); print(sb.toString()); } }dart.vm.product 
相關文章
相關標籤/搜索