blob: 5de75d89326c45aec01155c345459399ba694a00 [file] [log] [blame]
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:analyzer/instrumentation/instrumentation.dart';
/// An [InstrumentationLogger] that writes to a file (as opposed to an external
/// source or in-memory source etc.)
class FileInstrumentationLogger implements InstrumentationLogger {
final String filePath;
IOSink _sink;
FileInstrumentationLogger(this.filePath) {
File file = new File(filePath);
_sink = file.openWrite();
}
@override
void log(String message) {
_sink.writeln(message);
}
@override
Future shutdown() async {
await _sink.close();
_sink = null;
}
}