| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
System.Tail
Contents
Description
File tailing library with multi-subscriber support.
This library provides a Haskell API for tail -f style file streaming
using STM, Async, and system processes.
Example usage:
import System.Tail main :: IO () main = do tail <-tailFile100 "/var/log/app.log" subscriber <-tailSubscribetail -- Read from subscriber...tailStoptail
Synopsis
- data Tail
- tailFile :: HasCallStack => Int -> FilePath -> IO Tail
- tailStop :: Tail -> IO ()
- tailSubscribe :: Tail -> IO (CircularBuffer Text)
Core Types
Represent `tail -f`'ing a file in Haskell
Instances
Operations
tailFile :: HasCallStack => Int -> FilePath -> IO Tail Source #
Create a new Tail handle for the given file path with specified buffer size.
The tail process starts immediately and begins reading from the file.
New subscribers will receive a ring buffer containing the last bufferSize lines.
tailStop :: Tail -> IO () Source #
Signal the tail process to stop reading the file.
This will terminate the underlying tail process and close all subscriber queues.
tailSubscribe :: Tail -> IO (CircularBuffer Text) Source #
Subscribe to tail output and receive a CircularBuffer for reading lines.
The returned buffer will contain any previously read lines from the ring buffer, plus all new lines as they are read from the file.
Use drain to read from the buffer.