aboutsummaryrefslogtreecommitdiff
path: root/server/src/Thermoprint/Server/Printer/Debug/Delayed.hs
blob: c002d43025fcf8405aa158372b832d05e8004a41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- | A printer which blocks for a certain time and writes to log
module Thermoprint.Server.Printer.Debug.Delayed
       ( delayedDebugPrint
       ) where

import Control.Monad.IO.Class
import Control.Applicative

import Control.Concurrent (threadDelay)

import Thermoprint.Server.Printer
import Thermoprint.Server.Printer.Debug

delayedDebugPrint :: Int -> PrinterMethod
-- ^ Wait the given number of microseconds before invoking 'debugPrint'
delayedDebugPrint wait = PM $ \po -> let (PM debugPrint') = debugPrint in liftIO (threadDelay wait) *> debugPrint' po