diff options
-rw-r--r-- | graylog.cabal | 2 | ||||
-rw-r--r-- | 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 | |||
28 | , aeson | 28 | , aeson |
29 | , aeson-casing | 29 | , aeson-casing |
30 | , bytestring | 30 | , bytestring |
31 | , mwc-random | ||
32 | , network | 31 | , network |
32 | , random | ||
33 | , scientific | 33 | , scientific |
34 | , text | 34 | , text |
35 | , time | 35 | , 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 | |||
6 | 6 | ||
7 | import Data.Aeson | 7 | import Data.Aeson |
8 | import qualified Data.ByteString.Lazy as LBS | 8 | import qualified Data.ByteString.Lazy as LBS |
9 | import Data.Word | ||
9 | import Network.Socket.ByteString.Lazy | 10 | import Network.Socket.ByteString.Lazy |
10 | import System.Random.MWC | 11 | import System.Random |
11 | 12 | ||
12 | import Graylog.Gelf as Export | 13 | import Graylog.Gelf as Export |
13 | import Graylog.Types as Export | 14 | import Graylog.Types as Export |
@@ -16,7 +17,15 @@ sendLog :: Graylog -> GELF -> IO () | |||
16 | sendLog glog msg = mapM_ (send $ _graylogSocket glog) cks | 17 | sendLog glog msg = mapM_ (send $ _graylogSocket glog) cks |
17 | where | 18 | where |
18 | raw = encode msg | 19 | raw = encode msg |
19 | cks = chunky raw | 20 | cks = chunky glog raw |
20 | 21 | ||
21 | chunky :: LBS.ByteString -> [LBS.ByteString] | 22 | chunky :: Graylog -> LBS.ByteString -> IO [LBS.ByteString] |
22 | chunky = undefined | 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 | ||