on master help sign in
Update examples
commitc847454b322395b135c64e6b2b39645c3c6e9ec8 authorMichael Xavier <michael@michaelxavier.net> dateMon 3 Apr 2017, 15:54 (10 years ago) parent5d8d474
2 files changed+12−10
katip/examples/example.hs+6−5 katip/examples/example_lens.hs+6−5
katip/examples/example.hs+6−5
@@ -28,15 +28,14 @@ import Katip
2828-- lens_example for a slightly cleaner and more general pattern.
2929main :: IO ()
3030main = do
31− le <- initLogEnv "MyApp" "production"
3231 -- We'll set up a scribe that logs to stdout and will only log item
3332 -- fields permitted for Verbosity 2 and will throw out Debug
3433 -- messages entirely. Note that katip provides facilities like
3534 -- 'unregisterScribe' and 'registerScribe' to make it possible to
3635 -- hot-swap scribes at runtime if you need to.
37− (handleScribe, finaliser) <- mkHandleScribe ColorIfTerminal stdout InfoS V2
38− let le' = registerScribe "stdout" handleScribe le
39− let s = MyState M.mempty mempty le'
36+ handleScribe <- mkHandleScribe ColorIfTerminal stdout InfoS V2
37+ le <- registerScribe "stdout" handleScribe defaultScribeSettings =<< initLogEnv "MyApp" "production"
38+ let s = MyState M.mempty mempty le
4039 runStack s $ do
4140 $(logTM) InfoS "Started"
4241 -- this will add "confrabulation" to the current namespace, making
@@ -52,7 +51,9 @@ main = do
5251 $(logTM) InfoS "Namespace and context are back to normal"
5352 noLogging $
5453 $(logTM) DebugS "You'll never see this log message!"
55− finaliser
54+ -- This blocking call flushes all in-flight messages through
55+ -- handlers and then finalizes each scribe.
56+ void (closeScribes le)
5657
5758-------------------------------------------------------------------------------
5859newtype ConfrabLogCTX = ConfrabLogCTX Int
katip/examples/example_lens.hs+6−5
@@ -44,15 +44,14 @@ makeClassy ''MyState
4444-- lens_example for a slightly cleaner and more general pattern.
4545main :: IO ()
4646main = do
47− le <- initLogEnv "MyApp" "production"
4847 -- We'll set up a scribe that logs to stdout and will only log item
4948 -- fields permitted for Verbosity 2 and will throw out Debug
5049 -- messages entirely. Note that katip provides facilities like
5150 -- 'unregisterScribe' and 'registerScribe' to make it possible to
5251 -- hot-swap scribes at runtime if you need to.
53− (handleScribe, finaliser) <- mkHandleScribe ColorIfTerminal stdout InfoS V2
54− let le' = registerScribe "stdout" handleScribe le
55− let s = MyState M.mempty mempty le'
52+ handleScribe <- mkHandleScribe ColorIfTerminal stdout InfoS V2
53+ le <- registerScribe "stdout" handleScribe defaultScribeSettings =<< initLogEnv "MyApp" "production"
54+ let s = MyState M.mempty mempty le
5655 runStack s $ do
5756 $(logTM) InfoS "Started"
5857 -- this will add "confrabulation" to the current namespace, making
@@ -68,7 +67,9 @@ main = do
6867 $(logTM) InfoS "Namespace and context are back to normal"
6968 noLogging $
7069 $(logTM) DebugS "You'll never see this log message!"
71− finaliser
70+ -- This blocking call flushes all in-flight messages through
71+ -- handlers and then finalizes each scribe.
72+ void (closeScribes le)
7273
7374
7475-------------------------------------------------------------------------------