import 'package:flutter/foundation.dart';

class LogManager {
  static final LogManager _instance = LogManager._internal();
  factory LogManager() => _instance;
  LogManager._internal();

  final ValueNotifier<List<String>> logs = ValueNotifier([]);

  void addLog(String message) {
    try {
      final timestamp = DateTime.now().toString().split(' ')[1].split('.')[0];
      final logMessage = "[$timestamp] $message";

      logs.value = [logMessage, ...logs.value];
    } catch (e) {
      print('LogManager Error: $e');
    }
  }

  void clear() {
    logs.value = [];
  }
}
