import 'package:logger/logger.dart';

class LogHelper {
  // 单例对象
  static final LogHelper _singleton = LogHelper._internal();

  // Logger实例
  late Logger _logger;

  // 私有构造函数
  LogHelper._internal() {
    _logger = Logger();
  }

  // 工厂构造函数返回单例对象
  factory LogHelper() => _singleton;

  // 输出不同级别的日志
  void e(dynamic message, [dynamic error, StackTrace? stackTrace]) =>
      _logger.e(message, error: error, stackTrace: stackTrace);
  void w(dynamic message, [dynamic error, StackTrace? stackTrace]) =>
      _logger.w(message, error: error, stackTrace: stackTrace);
  void i(dynamic message) => _logger.i(message);
  void d(dynamic message) => _logger.d(message);
}
