aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrewRademacher <andrewrademacher@gmail.com>2016-02-28 14:38:16 -0600
committerAndrewRademacher <andrewrademacher@gmail.com>2016-02-28 14:38:16 -0600
commitd9a5d441ca9b5ae766311702557bf9f1ff0255b1 (patch)
tree3ef695c2ec24e5a53167d726a6af626778a4809a
parentf82a8dfc7e9b79ca6b88235d7297252adbb6d364 (diff)
downloadhaskell-graylog-d9a5d441ca9b5ae766311702557bf9f1ff0255b1.tar.gz
haskell-graylog-d9a5d441ca9b5ae766311702557bf9f1ff0255b1.tar.zst
haskell-graylog-d9a5d441ca9b5ae766311702557bf9f1ff0255b1.zip
Added readme, license, and light commenting.
-rw-r--r--LICENSE25
-rw-r--r--README.md16
-rw-r--r--graylog.cabal7
-rw-r--r--src/Graylog/Gelf.hs2
-rw-r--r--src/Graylog/Types.hs8
-rw-r--r--src/Graylog/UDP.hs1
6 files changed, 39 insertions, 20 deletions
diff --git a/LICENSE b/LICENSE
index d3a554d..ac298e2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,20 +1,13 @@
1Copyright (c) 2016 Andrew Rademacher 1 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2 Version 2, December 2004
2 3
4 Copyright (C) 2016 Andrew Rademacher <andrewrademacher@gmail.com>
3 5
4Permission is hereby granted, free of charge, to any person obtaining a copy of 6 Everyone is permitted to copy and distribute verbatim or modified
5this software and associated documentation files (the "Software"), to deal in 7 copies of this license document, and changing it is allowed as long
6the Software without restriction, including without limitation the rights to 8 as the name is changed.
7use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8of the Software, and to permit persons to whom the Software is furnished to do
9so, subject to the following conditions:
10 9
11The above copyright notice and this permission notice shall be included in all 10 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
12copies or substantial portions of the Software. 11 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
13 12
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 0. You just DO WHAT THE FUCK YOU WANT TO.
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..94fefbe
--- /dev/null
+++ b/README.md
@@ -0,0 +1,16 @@
1# Graylog
2This library provides support for sending GELF formatted messages to Graylog.
3Currently the UDP chunked method is the only method supported.
4
5```haskell
6import Graylog.UDP
7
8main :: IO ()
9main = do
10 eglog <- openGraylog "192.168.99.100" "12201" defaultChunkSize
11 case eglog of
12 Left e -> assertFailure e
13 Right g -> sendLog g sample >> closeGraylog g
14 where
15 sample = simpleGelf "localhost" "hello world!"
16```
diff --git a/graylog.cabal b/graylog.cabal
index 47c8b7d..c1b0288 100644
--- a/graylog.cabal
+++ b/graylog.cabal
@@ -1,9 +1,10 @@
1name: graylog 1name: graylog
2version: 0.1.0.0 2version: 0.1.0.0
3synopsis: Support for graylog output. 3synopsis: Support for graylog output.
4description: Please see README.md 4description: Support for sending GELF formatted messages to graylog over
5homepage: http://github.com/githubuser/graylog#readme 5 chunked UDP.
6license: MIT 6homepage: https://github.com/AndrewRademacher/haskell-graylog
7license: WTFPL
7license-file: LICENSE 8license-file: LICENSE
8author: Andrew Rademacher 9author: Andrew Rademacher
9maintainer: andrewrademacher@gmail.com 10maintainer: andrewrademacher@gmail.com
diff --git a/src/Graylog/Gelf.hs b/src/Graylog/Gelf.hs
index cd68e05..ee17e3d 100644
--- a/src/Graylog/Gelf.hs
+++ b/src/Graylog/Gelf.hs
@@ -2,6 +2,8 @@
2{-# LANGUAGE DeriveGeneric #-} 2{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE OverloadedStrings #-} 3{-# LANGUAGE OverloadedStrings #-}
4 4
5-- | Default formatting for Graylog messages,
6-- see http://docs.graylog.org/en/latest/pages/gelf.html
5module Graylog.Gelf where 7module Graylog.Gelf where
6 8
7import Data.Aeson (ToJSON (..), Value (..), genericToJSON, 9import Data.Aeson (ToJSON (..), Value (..), genericToJSON,
diff --git a/src/Graylog/Types.hs b/src/Graylog/Types.hs
index 5c32a8b..5ec779b 100644
--- a/src/Graylog/Types.hs
+++ b/src/Graylog/Types.hs
@@ -22,8 +22,11 @@ import qualified Data.Text as T
22import Network.BSD 22import Network.BSD
23import Network.Socket 23import Network.Socket
24 24
25-- | The maximum size of each datagram when using UDP transit methods.
25type ChunkSize = Word 26type ChunkSize = Word
26 27
28-- | Handle for a socket connected to Graylog. In some cases this socket
29-- is UDP and will not have a maintained session.
27data Graylog 30data Graylog
28 = Graylog 31 = Graylog
29 { _graylogHost :: String 32 { _graylogHost :: String
@@ -38,7 +41,10 @@ defaultChunkSize :: ChunkSize
38defaultChunkSize = 8192 41defaultChunkSize = 8192
39 42
40openGraylog 43openGraylog
41 :: HostName -> ServiceName -> ChunkSize -> IO (Either String Graylog) 44 :: HostName -- ^ The host on which graylog is running.
45 -> ServiceName -- ^ The port on which graylog is running.
46 -> ChunkSize -- ^ The maximum size of each UDP datagram.
47 -> IO (Either String Graylog)
42openGraylog h p cksize 48openGraylog h p cksize
43 | cksize < 1024 = return $ Left "ChunkSize must be at least 1024." 49 | cksize < 1024 = return $ Left "ChunkSize must be at least 1024."
44 | otherwise = getAddrInfo Nothing (Just h) (Just p) >>= \case 50 | otherwise = getAddrInfo Nothing (Just h) (Just p) >>= \case
diff --git a/src/Graylog/UDP.hs b/src/Graylog/UDP.hs
index cd7fe5a..7c8eb84 100644
--- a/src/Graylog/UDP.hs
+++ b/src/Graylog/UDP.hs
@@ -1,3 +1,4 @@
1-- | UDP Chunked support for sending messages to graylog.
1module Graylog.UDP 2module Graylog.UDP
2 ( sendLog 3 ( sendLog
3 4