@@ -20,6 +20,7 @@ import qualified Data.HashMap.Strict as HM
2020-------------------------------------------------------------------------------
2121import Katip.Core
2222import Katip.Format.Time (formatAsLogTime)
23+import Katip.Scribes.Handle.FileOwner
2324-------------------------------------------------------------------------------
2425
2526
@@ -106,6 +107,26 @@ mkHandleScribeWithFormatter itemFormatter cs h permitF verb = do
106107 BL.hPutStr h $ toLazyByteString $ itemFormatter colorize verb i
107108 return $ Scribe logger (hFlush h) permitF
108109
110+-- | Just like mkFileScribeWithFormatter but does it with FileOwner. You can
111+-- rotate your logs with commands to the FileOwner directly. This scribe will
112+-- send messages to the given FileOwner
113+mkFileOwnerScribeWithFormatter :: (forall a . LogItem a => ItemFormatter a)
114+ -> ColorStrategy
115+ -> FileOwner
116+ -> PermitFunc
117+ -> Verbosity
118+ -> IO Scribe
119+mkFileOwnerScribeWithFormatter itemFormatter cs owner permitF verb = do
120+ let
121+ colorize = case cs of
122+ ColorIfTerminal -> False
123+ -- File is never a terminal
124+ ColorLog b -> b
125+ logger item = do
126+ writeFileOwner owner $ toLazyByteString
127+ $ itemFormatter colorize verb item
128+ scribe = Scribe logger (fileOwnerControl owner CloseMsg) permitF
129+ return scribe
109130
110131-------------------------------------------------------------------------------
111132-- | A specialization of 'mkHandleScribe' that takes a 'FilePath'