一个简易的Log工具类,代码很短,如下:
import 'package:flutter/foundation.dart';
class Log{
static void info<T>(T content){
DateTime date = new DateTime.now();
if (kDebugMode) {
print('------> 🟩 [INFO] ${date.hour}:${date.minute}:${date.second}:${date.millisecond} || $content 🟩');
}
}
static void debug<T>(T content){
DateTime date = new DateTime.now();
if (kDebugMode) {
print('------> 🟦 [DEBUG] ${date.hour}:${date.minute}:${date.second}:${date.millisecond} || $content 🟦');
}
}
static void warn<T>(T content){
DateTime date = new DateTime.now();
if (kDebugMode) {
print('------> 🟨 [WARN] ${date.hour}:${date.minute}:${date.second}:${date.millisecond} || $content 🟨');
}
}
static void error<T>(T content){
DateTime date = new DateTime.now();
if (kDebugMode) {
print('------> 🟥 [ERROR] ${date.hour}:${date.minute}:${date.second}:${date.millisecond} || $content 🟥');
}
}
}