aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--graylog.cabal26
-rw-r--r--src/Graylog/Gelf.hs31
-rw-r--r--src/Graylog/UDP.hs19
-rw-r--r--test/Main.hs12
-rw-r--r--test/Test/Graylog/UDP.hs13
5 files changed, 78 insertions, 23 deletions
diff --git a/graylog.cabal b/graylog.cabal
index d7d1163..b3c1a53 100644
--- a/graylog.cabal
+++ b/graylog.cabal
@@ -24,7 +24,33 @@ library
24 24
25 , aeson 25 , aeson
26 , aeson-casing 26 , aeson-casing
27 , network
27 , scientific 28 , scientific
28 , text 29 , text
29 , time 30 , time
30 , vector 31 , vector
32
33test-suite test-state
34 type: exitcode-stdio-1.0
35 main-is: Main.hs
36 hs-source-dirs: test
37 default-language: Haskell2010
38
39 ghc-options: -Wall -threaded -with-rtsopts=-N -rtsopts
40
41 other-modules: Test.Graylog.UDP
42
43 build-depends: base ==4.*
44
45 , graylog
46
47 , aeson
48 , aeson-casing
49 , network
50 , scientific
51 , tasty
52 , tasty-hunit
53 , text
54 , time
55 , vector
56
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
7import Data.Aeson (ToJSON (..), Value (..), genericToJSON, 7import Data.Aeson (ToJSON (..), Value (..), genericToJSON,
8 toJSON) 8 toJSON)
9import Data.Aeson.Casing 9import Data.Aeson.Casing
10import Data.Scientific
11import Data.Text (Text) 10import Data.Text (Text)
12import Data.Time 11import Data.Time
13import Data.Typeable 12import Data.Typeable
14import Data.Vector
15import GHC.Generics 13import GHC.Generics
16 14
17data GELF 15data 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
68data Field
69 = FieldString Text
70 | FieldNumber Scientific
71 deriving (Eq, Show, Typeable, Generic)
72
73instance 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 @@
1module Graylog.UDP
2 ( Graylog (..)
3 , sendLog
4
5 , module Graylog.Gelf
6 ) where
7
8import Network.Socket
9
10import Graylog.Gelf
11
12data Graylog
13 = Graylog
14 { _graylogHost :: String
15 , _graylogPort :: String
16 }
17
18sendLog :: Graylog -> GELF -> IO ()
19sendLog glog msg = undefined
diff --git a/test/Main.hs b/test/Main.hs
new file mode 100644
index 0000000..604b65a
--- /dev/null
+++ b/test/Main.hs
@@ -0,0 +1,12 @@
1import qualified Test.Graylog.UDP (tests)
2
3import Test.Tasty
4
5main :: IO ()
6main = defaultMain tests
7
8tests :: TestTree
9tests = testGroup "Graylog Library"
10 [ Test.Graylog.UDP.tests
11 ]
12
diff --git a/test/Test/Graylog/UDP.hs b/test/Test/Graylog/UDP.hs
new file mode 100644
index 0000000..67da6fe
--- /dev/null
+++ b/test/Test/Graylog/UDP.hs
@@ -0,0 +1,13 @@
1module Test.Graylog.UDP where
2
3import Test.Tasty
4import Test.Tasty.HUnit
5
6tests :: TestTree
7tests = testGroup "Test.Graylog.UDP"
8 [ testCase "Validation: Something" case_validateSomething
9 ]
10
11case_validateSomething :: IO ()
12case_validateSomething = return ()
13