]> git.immae.eu Git - github/fretlink/haskell-graylog.git/blame - src/Graylog/UDP.hs
Framed UDP function.
[github/fretlink/haskell-graylog.git] / src / Graylog / UDP.hs
CommitLineData
15981d57 1module Graylog.UDP
c91dbdc0 2 ( sendLog
15981d57 3
2ff46fce 4 , module Export
15981d57
A
5 ) where
6
c91dbdc0
A
7import Data.Aeson
8import qualified Data.ByteString.Lazy as LBS
640e69ef 9import Data.Word
c91dbdc0 10import Network.Socket.ByteString.Lazy
640e69ef 11import System.Random
c91dbdc0
A
12
13import Graylog.Gelf as Export
14import Graylog.Types as Export
15981d57
A
15
16sendLog :: Graylog -> GELF -> IO ()
c91dbdc0
A
17sendLog glog msg = mapM_ (send $ _graylogSocket glog) cks
18 where
19 raw = encode msg
640e69ef 20 cks = chunky glog raw
2ff46fce 21
640e69ef
A
22chunky :: Graylog -> LBS.ByteString -> IO [LBS.ByteString]
23chunky glog raw = do
24 groupId <- randomIO
25 splitAt gsize
26 where
27 magic = undefined
28 seq = undefined
29 total = undefined
30 hlen = 12
31 gsize = (fromIntegral (_graylogChunkSize glog)) - hlen