https://github.com/cathive/dart-file-tailer
File tailing functionality for Dart/Flutter.
https://github.com/cathive/dart-file-tailer
dart-library dart-package
Last synced: about 2 months ago
JSON representation
File tailing functionality for Dart/Flutter.
- Host: GitHub
- URL: https://github.com/cathive/dart-file-tailer
- Owner: cathive
- License: bsd-3-clause
- Created: 2024-07-10T13:37:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-15T19:51:14.000Z (over 1 year ago)
- Last Synced: 2025-01-17T01:08:09.557Z (over 1 year ago)
- Topics: dart-library, dart-package
- Language: Dart
- Homepage: https://pub.dev/packages/file_tailer
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# file_tailer
A cross-platform file tailing library for Dart.
The file_tailer package provides functionality to read the stream the contents of a file to which data might be appended. This is especially useful for log files.
The functionality of this library should be similar to the experience when using the `tail`
command on the shell.
## Using
The file_tailer library was designed to be used without a prefix.
```dart
import 'package:file_tailer/file_tailer.dart';
```
The most common way to use this library to stream log files is by handling the data that is emitted
by tailing a file:
```dart
import 'dart:convert' show LineSplitter, utf8;
import 'dart:io' show File, stderr, stdout;
import 'package:file_tailer/file_tailer.dart' show tailFile;
void main(List arguments) {
if (arguments.length != 1) {
stderr.write('You need to provide exactly one file to be tailed.\n');
}
final (stream, _) = tailFile(File(arguments.first), follow: true, bytes: '+0');
stream
.transform(utf8.decoder)
.transform(const LineSplitter())
.forEach((line) async => stdout.write('$line\n'));
}
```