aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Graylog/UDP.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Graylog/UDP.hs')
-rw-r--r--src/Graylog/UDP.hs40
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
7import Data.Aeson 7import Data.Aeson
8import qualified Data.ByteString.Lazy as LBS 8{-import Data.ByteString.Builder-}
9import Data.Word 9{-import qualified Data.ByteString.Lazy as LBS-}
10{-import Data.Word-}
10import Network.Socket.ByteString.Lazy 11import Network.Socket.ByteString.Lazy
11import System.Random 12{-import System.Random-}
12 13
13import Graylog.Gelf as Export 14import Graylog.Gelf as Export
14import Graylog.Types as Export 15import Graylog.Types as Export
15 16
16sendLog :: Graylog -> GELF -> IO () 17sendLog :: Graylog -> GELF -> IO ()
17sendLog glog msg = mapM_ (send $ _graylogSocket glog) cks 18sendLog 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
22chunky :: Graylog -> LBS.ByteString -> IO [LBS.ByteString] 25{-sendLog :: Graylog -> GELF -> IO ()-}
23chunky 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-}