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) 编辑 收藏 举报