]> git.immae.eu Git - github/fretlink/haskell-graylog.git/commitdiff
Framed UDP function.
authorAndrewRademacher <andrew.rademacher@smrxt.com>
Sun, 28 Feb 2016 02:23:26 +0000 (20:23 -0600)
committerAndrewRademacher <andrew.rademacher@smrxt.com>
Sun, 28 Feb 2016 02:23:26 +0000 (20:23 -0600)
graylog.cabal
src/Graylog/UDP.hs

index 3eaa8125da3a2bf5162c8cae8c4df5bdf07b3503..cc6b2d82ea666fe4630bcf8df9b0a69d000e3820 100644 (file)
@@ -28,8 +28,8 @@ library
                      ,  aeson
                      ,  aeson-casing
                      ,  bytestring
-                     ,  mwc-random
                      ,  network
+                     ,  random
                      ,  scientific
                      ,  text
                      ,  time
index dc172b906ed5fafe7e821e027b9ce76073400d9e..656cbc88676b15bd46e988afcfd2bc583c1b4558 100644 (file)
@@ -6,8 +6,9 @@ module Graylog.UDP
 
 import           Data.Aeson
 import qualified Data.ByteString.Lazy           as LBS
+import           Data.Word
 import           Network.Socket.ByteString.Lazy
-import           System.Random.MWC
+import           System.Random
 
 import           Graylog.Gelf                   as Export
 import           Graylog.Types                  as Export
@@ -16,7 +17,15 @@ sendLog :: Graylog -> GELF -> IO ()
 sendLog glog msg = mapM_ (send $ _graylogSocket glog) cks
    where
       raw = encode msg
-      cks = chunky raw
+      cks = chunky glog raw
 
-chunky :: LBS.ByteString -> [LBS.ByteString]
-chunky = undefined
+chunky :: Graylog -> LBS.ByteString -> IO [LBS.ByteString]
+chunky glog raw = do
+   groupId <- randomIO
+   splitAt gsize
+   where
+      magic = undefined
+      seq   = undefined
+      total = undefined
+      hlen  = 12
+      gsize = (fromIntegral (_graylogChunkSize glog)) - hlen