]>
Commit | Line | Data |
---|---|---|
15981d57 | 1 | module Graylog.UDP |
c91dbdc0 | 2 | ( sendLog |
15981d57 | 3 | |
2ff46fce | 4 | , module Export |
15981d57 A |
5 | ) where |
6 | ||
c91dbdc0 A |
7 | import Data.Aeson |
8 | import qualified Data.ByteString.Lazy as LBS | |
640e69ef | 9 | import Data.Word |
c91dbdc0 | 10 | import Network.Socket.ByteString.Lazy |
640e69ef | 11 | import System.Random |
c91dbdc0 A |
12 | |
13 | import Graylog.Gelf as Export | |
14 | import Graylog.Types as Export | |
15981d57 A |
15 | |
16 | sendLog :: Graylog -> GELF -> IO () | |
c91dbdc0 A |
17 | sendLog glog msg = mapM_ (send $ _graylogSocket glog) cks |
18 | where | |
19 | raw = encode msg | |
640e69ef | 20 | cks = chunky glog raw |
2ff46fce | 21 | |
640e69ef A |
22 | chunky :: Graylog -> LBS.ByteString -> IO [LBS.ByteString] |
23 | chunky 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 |