]> git.immae.eu Git - github/fretlink/haskell-graylog.git/commitdiff
Added readme, license, and light commenting.
authorAndrewRademacher <andrewrademacher@gmail.com>
Sun, 28 Feb 2016 20:38:16 +0000 (14:38 -0600)
committerAndrewRademacher <andrewrademacher@gmail.com>
Sun, 28 Feb 2016 20:38:16 +0000 (14:38 -0600)
LICENSE
README.md [new file with mode: 0644]
graylog.cabal
src/Graylog/Gelf.hs
src/Graylog/Types.hs
src/Graylog/UDP.hs

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