diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-02-25 17:56:21 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-02-25 17:56:21 +0000 |
commit | 4d7ecb10ada3115da14fb7baefe9cb1b510bb6ae (patch) | |
tree | b46b2b22ee73d76f419d87a23294d8d982346eb7 | |
parent | f515803694d7f8430b064f16a5a923b09ba70650 (diff) | |
download | thermoprint-4d7ecb10ada3115da14fb7baefe9cb1b510bb6ae.tar thermoprint-4d7ecb10ada3115da14fb7baefe9cb1b510bb6ae.tar.gz thermoprint-4d7ecb10ada3115da14fb7baefe9cb1b510bb6ae.tar.bz2 thermoprint-4d7ecb10ada3115da14fb7baefe9cb1b510bb6ae.tar.xz thermoprint-4d7ecb10ada3115da14fb7baefe9cb1b510bb6ae.zip |
delayed debugging printer
-rw-r--r-- | server/default-conf/Main.hs | 1 | ||||
-rw-r--r-- | server/src/Thermoprint/Server/Printer/Debug/Delayed.hs | 16 | ||||
-rw-r--r-- | server/thermoprint-server.cabal | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/server/default-conf/Main.hs b/server/default-conf/Main.hs index cbfc476..f0b7f43 100644 --- a/server/default-conf/Main.hs +++ b/server/default-conf/Main.hs | |||
@@ -20,4 +20,5 @@ main = thermoprintServer True (Nat runSqlite) $ def `withPrinters` printers | |||
20 | runSqlite = runStderrLoggingT . withSqlitePool "thermoprint.sqlite" 1 . runReaderT | 20 | runSqlite = runStderrLoggingT . withSqlitePool "thermoprint.sqlite" 1 . runReaderT |
21 | 21 | ||
22 | printers = [ (pure debugPrint, def) | 22 | printers = [ (pure debugPrint, def) |
23 | , (pure $ delayedDebugPrint (10 * 10^6), def) | ||
23 | ] | 24 | ] |
diff --git a/server/src/Thermoprint/Server/Printer/Debug/Delayed.hs b/server/src/Thermoprint/Server/Printer/Debug/Delayed.hs new file mode 100644 index 0000000..c002d43 --- /dev/null +++ b/server/src/Thermoprint/Server/Printer/Debug/Delayed.hs | |||
@@ -0,0 +1,16 @@ | |||
1 | -- | A printer which blocks for a certain time and writes to log | ||
2 | module Thermoprint.Server.Printer.Debug.Delayed | ||
3 | ( delayedDebugPrint | ||
4 | ) where | ||
5 | |||
6 | import Control.Monad.IO.Class | ||
7 | import Control.Applicative | ||
8 | |||
9 | import Control.Concurrent (threadDelay) | ||
10 | |||
11 | import Thermoprint.Server.Printer | ||
12 | import Thermoprint.Server.Printer.Debug | ||
13 | |||
14 | delayedDebugPrint :: Int -> PrinterMethod | ||
15 | -- ^ Wait the given number of microseconds before invoking 'debugPrint' | ||
16 | delayedDebugPrint wait = PM $ \po -> let (PM debugPrint') = debugPrint in liftIO (threadDelay wait) *> debugPrint' po | ||
diff --git a/server/thermoprint-server.cabal b/server/thermoprint-server.cabal index bc3650b..f98cac1 100644 --- a/server/thermoprint-server.cabal +++ b/server/thermoprint-server.cabal | |||
@@ -25,6 +25,7 @@ library | |||
25 | , Thermoprint.Server.Queue | 25 | , Thermoprint.Server.Queue |
26 | , Thermoprint.Server.Printer | 26 | , Thermoprint.Server.Printer |
27 | , Thermoprint.Server.Printer.Debug | 27 | , Thermoprint.Server.Printer.Debug |
28 | , Thermoprint.Server.Printer.Debug.Delayed | ||
28 | , Thermoprint.Server.Printer.Generic | 29 | , Thermoprint.Server.Printer.Generic |
29 | other-modules: Thermoprint.Server.Database.Instances | 30 | other-modules: Thermoprint.Server.Database.Instances |
30 | , Paths_thermoprint_server | 31 | , Paths_thermoprint_server |