FileLogHandler constructor

FileLogHandler(
  1. String filePath
)

Creates a new file log handler.

filePath The path to the log file.

Implementation

FileLogHandler(String filePath) : _file = File(filePath) {
  try {
    // Create directory if it doesn't exist
    final dir = Directory(_file.parent.path);
    if (!dir.existsSync()) {
      dir.createSync(recursive: true);
    }

    // Open file for writing in append mode
    _sink = _file.openWrite(mode: FileMode.append);
  } catch (e) {
    print('Error initializing file logger: $e');
    rethrow;
  }
}