on master help sign in
FileOwner
commitc5e9b33cfa48a8fe9acda861391d8a3a401dd9db authorAleksey Uimanov <s9gf4ult@gmail.com> dateWed 10 Jul 2019, 20:46 (7 years ago) parent686ae62
2 files changed+46−17
katip/katip.cabal+18−17 katip/src/Katip/Scribes/RotatingHandler.hs+28
katip/katip.cabal+18−17
@@ -36,12 +36,12 @@ flag lib-Werror
3636 manual: True
3737
3838library
39− exposed-modules:
40− Katip
41− Katip.Core
42− Katip.Format.Time
43− Katip.Monadic
44− Katip.Scribes.Handle
39+ exposed-modules: Katip
40+ , Katip.Core
41+ , Katip.Format.Time
42+ , Katip.Monadic
43+ , Katip.Scribes.Handle
44+ , Katip.Scribes.RotatingHandler
4545
4646 default-extensions:
4747 DeriveGeneric
@@ -59,27 +59,28 @@ library
5959 , auto-update >= 0.1
6060 , bytestring >= 0.9
6161 , containers >=0.4
62+ , deepseq
6263 , either >= 4
63− , safe-exceptions >= 0.1.0.0
6464 , hostname >=1.0
65+ , microlens >= 0.2.0.0
66+ , microlens-th >= 0.1.0.0
67+ , monad-control >= 1.0
68+ , mtl >= 2.0
6569 , old-locale >= 1.0
70+ , resourcet >= 1.1
71+ , safe-exceptions >= 0.1.0.0
72+ , scientific >= 0.3.3.0
73+ , semigroups
74+ , stm >= 2.4
6675 , string-conv >= 0.1
6776 , template-haskell >= 2.8
6877 , text >= 0.11
6978 , time >= 1
7079 , transformers >= 0.3
71− , transformers-compat
72− , unordered-containers >= 0.2
73− , monad-control >= 1.0
74− , mtl >= 2.0
7580 , transformers-base >= 0.3
76− , resourcet >= 1.1
77− , scientific >= 0.3.3.0
78− , microlens >= 0.2.0.0
79− , microlens-th >= 0.1.0.0
80− , semigroups
81+ , transformers-compat
8182 , unliftio-core >= 0.1
82− , stm >= 2.4
83+ , unordered-containers >= 0.2
8384
8485 hs-source-dirs: src
8586 default-language: Haskell2010
katip/src/Katip/Scribes/RotatingHandler.hsnew file+28
@@ -0,0 +1,28 @@
1+module Katip.Scribes.RotatingHandler where
2+
3+import Control.Concurrent.STM
4+import Control.DeepSeq
5+import Data.ByteString.Lazy as BL
6+
7+-- | File owner struct writing data to the file
8+-- sequentially. Automatic buffer flushing and log rotating.
9+data FileOwner = FileOwner
10+ { foDataQueune :: TBQueue BL.ByteString
11+
12+ }
13+
14+data ControlMsg
15+ = CloseMsg
16+ | FlushMsg
17+ | ReopenMsg
18+
19+newFileOwner :: FilePath -> Maybe Int -> IO FileOwner
20+newFileOwner = error "newFileOwner not implemented"
21+
22+fileOwnerControl :: FileOwner -> ControlMsg -> IO ()
23+fileOwnerControl = error "fileOwnerControl not implemented"
24+
25+writeFileOwner :: FileOwner -> BL.ByteString -> IO ()
26+writeFileOwner fo bs = do
27+ a <- return $!! bs
28+ atomically $ writeTBQueue (foDataQueune fo) $!! a