From 640e69ef77aea530af800741e453b05e2802d188 Mon Sep 17 00:00:00 2001 From: AndrewRademacher Date: Sat, 27 Feb 2016 20:23:26 -0600 Subject: Framed UDP function. --- graylog.cabal | 2 +- src/Graylog/UDP.hs | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/graylog.cabal b/graylog.cabal index 3eaa812..cc6b2d8 100644 --- a/graylog.cabal +++ b/graylog.cabal @@ -28,8 +28,8 @@ library , aeson , aeson-casing , bytestring - , mwc-random , network + , random , scientific , text , time diff --git a/src/Graylog/UDP.hs b/src/Graylog/UDP.hs index dc172b9..656cbc8 100644 --- a/src/Graylog/UDP.hs +++ b/src/Graylog/UDP.hs @@ -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 -- cgit v1.2.3