blob: d7ee12aa481251cb7a104caccb9ee11f437b5924 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
-- | A printer which just writes all jobs to log
module Thermoprint.Server.Printer.Debug
( debugPrint
) where
import Control.Monad.IO.Class
import Control.Monad.Trans.Resource
import Control.Monad.Logger
import Data.Text.Lazy (Text)
import qualified Data.Text.Lazy as TL
import qualified Data.Text as T
import Thermoprint.Printout
import Thermoprint.Server.Printer
import Data.List (intersperse)
import Data.Foldable (toList)
import Data.Monoid
debugPrint :: PrinterMethod
debugPrint = PM $ (>> return Nothing) . $(logDebugS) "Printer.Debug" . T.pack . show . cotext'
cotext' :: Printout -> Text
cotext' = mconcat . intersperse "\n\n" . map (mconcat . map cotext'' . toList) . toList
where
cotext'' (Cooked b) = cotext b
cotext'' (Raw _) = "[Raw]"
|