diff options
author | AndrewRademacher <andrewrademacher@gmail.com> | 2016-02-28 14:38:16 -0600 |
---|---|---|
committer | AndrewRademacher <andrewrademacher@gmail.com> | 2016-02-28 14:38:16 -0600 |
commit | d9a5d441ca9b5ae766311702557bf9f1ff0255b1 (patch) | |
tree | 3ef695c2ec24e5a53167d726a6af626778a4809a | |
parent | f82a8dfc7e9b79ca6b88235d7297252adbb6d364 (diff) | |
download | haskell-graylog-d9a5d441ca9b5ae766311702557bf9f1ff0255b1.tar.gz haskell-graylog-d9a5d441ca9b5ae766311702557bf9f1ff0255b1.tar.zst haskell-graylog-d9a5d441ca9b5ae766311702557bf9f1ff0255b1.zip |
Added readme, license, and light commenting.
-rw-r--r-- | LICENSE | 25 | ||||
-rw-r--r-- | README.md | 16 | ||||
-rw-r--r-- | graylog.cabal | 7 | ||||
-rw-r--r-- | src/Graylog/Gelf.hs | 2 | ||||
-rw-r--r-- | src/Graylog/Types.hs | 8 | ||||
-rw-r--r-- | src/Graylog/UDP.hs | 1 |
6 files changed, 39 insertions, 20 deletions
@@ -1,20 +1,13 @@ | |||
1 | Copyright (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 | ||
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of | 6 | Everyone is permitted to copy and distribute verbatim or modified |
5 | this software and associated documentation files (the "Software"), to deal in | 7 | copies of this license document, and changing it is allowed as long |
6 | the Software without restriction, including without limitation the rights to | 8 | as the name is changed. |
7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
8 | of the Software, and to permit persons to whom the Software is furnished to do | ||
9 | so, subject to the following conditions: | ||
10 | 9 | ||
11 | The above copyright notice and this permission notice shall be included in all | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
12 | copies or substantial portions of the Software. | 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
13 | 12 | ||
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. |
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
20 | SOFTWARE. | ||
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 | ||
2 | This library provides support for sending GELF formatted messages to Graylog. | ||
3 | Currently the UDP chunked method is the only method supported. | ||
4 | |||
5 | ```haskell | ||
6 | import Graylog.UDP | ||
7 | |||
8 | main :: IO () | ||
9 | main = 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 @@ | |||
1 | name: graylog | 1 | name: graylog |
2 | version: 0.1.0.0 | 2 | version: 0.1.0.0 |
3 | synopsis: Support for graylog output. | 3 | synopsis: Support for graylog output. |
4 | description: Please see README.md | 4 | description: Support for sending GELF formatted messages to graylog over |
5 | homepage: http://github.com/githubuser/graylog#readme | 5 | chunked UDP. |
6 | license: MIT | 6 | homepage: https://github.com/AndrewRademacher/haskell-graylog |
7 | license: WTFPL | ||
7 | license-file: LICENSE | 8 | license-file: LICENSE |
8 | author: Andrew Rademacher | 9 | author: Andrew Rademacher |
9 | maintainer: andrewrademacher@gmail.com | 10 | maintainer: 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 | ||
5 | module Graylog.Gelf where | 7 | module Graylog.Gelf where |
6 | 8 | ||
7 | import Data.Aeson (ToJSON (..), Value (..), genericToJSON, | 9 | import 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 | |||
22 | import Network.BSD | 22 | import Network.BSD |
23 | import Network.Socket | 23 | import Network.Socket |
24 | 24 | ||
25 | -- | The maximum size of each datagram when using UDP transit methods. | ||
25 | type ChunkSize = Word | 26 | type 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. | ||
27 | data Graylog | 30 | data Graylog |
28 | = Graylog | 31 | = Graylog |
29 | { _graylogHost :: String | 32 | { _graylogHost :: String |
@@ -38,7 +41,10 @@ defaultChunkSize :: ChunkSize | |||
38 | defaultChunkSize = 8192 | 41 | defaultChunkSize = 8192 |
39 | 42 | ||
40 | openGraylog | 43 | openGraylog |
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) | ||
42 | openGraylog h p cksize | 48 | openGraylog 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. | ||
1 | module Graylog.UDP | 2 | module Graylog.UDP |
2 | ( sendLog | 3 | ( sendLog |
3 | 4 | ||