diff options
author | AndrewRademacher <andrew.rademacher@smrxt.com> | 2016-02-24 17:24:19 -0600 |
---|---|---|
committer | AndrewRademacher <andrew.rademacher@smrxt.com> | 2016-02-24 17:24:19 -0600 |
commit | 15981d57cda18a19fcb3012172a9f0994abfd97a (patch) | |
tree | b309de32b39b432ea63a275cb3db7bc4d4dd5415 /src/Graylog | |
parent | 526966434f2248c1200427677dc3882668714693 (diff) | |
download | haskell-graylog-15981d57cda18a19fcb3012172a9f0994abfd97a.tar.gz haskell-graylog-15981d57cda18a19fcb3012172a9f0994abfd97a.tar.zst haskell-graylog-15981d57cda18a19fcb3012172a9f0994abfd97a.zip |
Added testing for UDP method.
Diffstat (limited to 'src/Graylog')
-rw-r--r-- | src/Graylog/Gelf.hs | 31 | ||||
-rw-r--r-- | src/Graylog/UDP.hs | 19 |
2 files changed, 27 insertions, 23 deletions
diff --git a/src/Graylog/Gelf.hs b/src/Graylog/Gelf.hs index 67e0de7..32b9321 100644 --- a/src/Graylog/Gelf.hs +++ b/src/Graylog/Gelf.hs | |||
@@ -7,24 +7,21 @@ module Graylog.Gelf where | |||
7 | import Data.Aeson (ToJSON (..), Value (..), genericToJSON, | 7 | import Data.Aeson (ToJSON (..), Value (..), genericToJSON, |
8 | toJSON) | 8 | toJSON) |
9 | import Data.Aeson.Casing | 9 | import Data.Aeson.Casing |
10 | import Data.Scientific | ||
11 | import Data.Text (Text) | 10 | import Data.Text (Text) |
12 | import Data.Time | 11 | import Data.Time |
13 | import Data.Typeable | 12 | import Data.Typeable |
14 | import Data.Vector | ||
15 | import GHC.Generics | 13 | import GHC.Generics |
16 | 14 | ||
17 | data GELF | 15 | data GELF |
18 | = GELF | 16 | = GELF |
19 | { _gelfVersion :: Version | 17 | { _gelfVersion :: Version |
20 | , _gelfHost :: Text | 18 | , _gelfHost :: Text |
21 | , _gelfShortMessage :: Text | 19 | , _gelfShortMessage :: Text |
22 | , _gelfFullMessage :: Maybe Text | 20 | , _gelfFullMessage :: Maybe Text |
23 | , _gelfTimestamp :: Maybe UTCTime | 21 | , _gelfTimestamp :: Maybe UTCTime |
24 | , _gelfLevel :: Maybe SyslogLevel | 22 | , _gelfLevel :: Maybe SyslogLevel |
25 | , _gelfLine :: Maybe Word | 23 | , _gelfLine :: Maybe Word |
26 | , _gelfFile :: Maybe Text | 24 | , _gelfFile :: Maybe Text |
27 | , _gelfAdditionalFields :: Vector Field | ||
28 | } | 25 | } |
29 | deriving (Show, Typeable, Generic) | 26 | deriving (Show, Typeable, Generic) |
30 | 27 | ||
@@ -62,15 +59,3 @@ instance ToJSON SyslogLevel where | |||
62 | toJSON Notice = Number 5 | 59 | toJSON Notice = Number 5 |
63 | toJSON Informational = Number 6 | 60 | toJSON Informational = Number 6 |
64 | toJSON Debug = Number 7 | 61 | toJSON Debug = Number 7 |
65 | |||
66 | -- | ||
67 | |||
68 | data Field | ||
69 | = FieldString Text | ||
70 | | FieldNumber Scientific | ||
71 | deriving (Eq, Show, Typeable, Generic) | ||
72 | |||
73 | instance ToJSON Field where | ||
74 | toJSON (FieldString s) = String s | ||
75 | toJSON (FieldNumber n) = Number n | ||
76 | |||
diff --git a/src/Graylog/UDP.hs b/src/Graylog/UDP.hs new file mode 100644 index 0000000..6aec108 --- /dev/null +++ b/src/Graylog/UDP.hs | |||
@@ -0,0 +1,19 @@ | |||
1 | module Graylog.UDP | ||
2 | ( Graylog (..) | ||
3 | , sendLog | ||
4 | |||
5 | , module Graylog.Gelf | ||
6 | ) where | ||
7 | |||
8 | import Network.Socket | ||
9 | |||
10 | import Graylog.Gelf | ||
11 | |||
12 | data Graylog | ||
13 | = Graylog | ||
14 | { _graylogHost :: String | ||
15 | , _graylogPort :: String | ||
16 | } | ||
17 | |||
18 | sendLog :: Graylog -> GELF -> IO () | ||
19 | sendLog glog msg = undefined | ||