tail
Safe HaskellNone
LanguageGHC2021

System.Tail

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 <- tailFile 100 "/var/log/app.log"
  subscriber <- tailSubscribe tail
  -- Read from subscriber...
  tailStop tail
Synopsis

Core Types

data Tail Source #

Represent `tail -f`'ing a file in Haskell

Instances

Instances details
Generic Tail Source # 
Instance details

Defined in System.Tail

Methods

from :: Tail -> Rep Tail x #

to :: Rep Tail x -> Tail #

type Rep Tail Source # 
Instance details

Defined in System.Tail

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.