diff options
Diffstat (limited to 'src/Graylog/UDP.hs')
-rw-r--r-- | src/Graylog/UDP.hs | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/Graylog/UDP.hs b/src/Graylog/UDP.hs index 656cbc8..c925d7e 100644 --- a/src/Graylog/UDP.hs +++ b/src/Graylog/UDP.hs | |||
@@ -5,27 +5,37 @@ module Graylog.UDP | |||
5 | ) where | 5 | ) where |
6 | 6 | ||
7 | import Data.Aeson | 7 | import Data.Aeson |
8 | import qualified Data.ByteString.Lazy as LBS | 8 | {-import Data.ByteString.Builder-} |
9 | import Data.Word | 9 | {-import qualified Data.ByteString.Lazy as LBS-} |
10 | {-import Data.Word-} | ||
10 | import Network.Socket.ByteString.Lazy | 11 | import Network.Socket.ByteString.Lazy |
11 | import System.Random | 12 | {-import System.Random-} |
12 | 13 | ||
13 | import Graylog.Gelf as Export | 14 | import Graylog.Gelf as Export |
14 | import Graylog.Types as Export | 15 | import Graylog.Types as Export |
15 | 16 | ||
16 | sendLog :: Graylog -> GELF -> IO () | 17 | sendLog :: Graylog -> GELF -> IO () |
17 | sendLog glog msg = mapM_ (send $ _graylogSocket glog) cks | 18 | sendLog glog msg = do |
19 | _ <- send (_graylogSocket glog) raw | ||
20 | print raw | ||
21 | return () | ||
18 | where | 22 | where |
19 | raw = encode msg | 23 | raw = encode msg |
20 | cks = chunky glog raw | ||
21 | 24 | ||
22 | chunky :: Graylog -> LBS.ByteString -> IO [LBS.ByteString] | 25 | {-sendLog :: Graylog -> GELF -> IO ()-} |
23 | chunky glog raw = do | 26 | {-sendLog glog msg = do-} |
24 | groupId <- randomIO | 27 | {-cks <- chunky glog raw-} |
25 | splitAt gsize | 28 | {-mapM_ (send $ _graylogSocket glog) cks-} |
26 | where | 29 | {-where-} |
27 | magic = undefined | 30 | {-raw = encode msg-} |
28 | seq = undefined | 31 | |
29 | total = undefined | 32 | {-chunky :: Graylog -> LBS.ByteString -> IO [LBS.ByteString]-} |
30 | hlen = 12 | 33 | {-chunky glog raw = do-} |
31 | gsize = (fromIntegral (_graylogChunkSize glog)) - hlen | 34 | {-groupId <- randomIO-} |
35 | {-splitAt gsize-} | ||
36 | {-where-} | ||
37 | {-magic = word8 0x1e <> word8 0x0f-} | ||
38 | {-seqNum = undefined-} | ||
39 | {-(count, excess) = quotRem (LBS.length raw) gzie-} | ||
40 | {-hlen = 12-} | ||
41 | {-gsize = (fromIntegral (_graylogChunkSize glog)) - hlen-} | ||