import 'package:logger/logger.dart';
import 'package:wyatt_clean_code/core/utils/wyatt_printer.dart';

extension ObjectX on Object {
  void log({Level level = Level.debug, String Function(Object obj)? wrap}) {
    final msg = wrap != null ? wrap(this) : this;
    WyattPrinter.get().log(level, msg);
  }

  /// Log a message at level [Level.verbose].
  void v({String Function(Object obj)? wrap}) =>
      log(level: Level.verbose, wrap: wrap);

  /// Log a message at level [Level.debug].
  void d({String Function(Object obj)? wrap}) => log(wrap: wrap);

  /// Log a message at level [Level.info].
  void i({String Function(Object obj)? wrap}) =>
      log(level: Level.info, wrap: wrap);

  /// Log a message at level [Level.warning].
  void w({String Function(Object obj)? wrap}) =>
      log(level: Level.warning, wrap: wrap);

  /// Log a message at level [Level.error].
  void e({String Function(Object obj)? wrap}) =>
      log(level: Level.error, wrap: wrap);

  /// Log a message at level [Level.wtf].
  void wtf({String Function(Object obj)? wrap}) =>
      log(level: Level.wtf, wrap: wrap);
}
