flutter 日志工具类

class LogUtils {
//dart.vm.product 环境标识位 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()); } }

 

posted on 2019-09-21 19:40  LoaderMan  阅读(2409)  评论(0编辑  收藏  举报

导航