[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 14:44:17 UTC 2010
The following commit has been merged in the master branch:
commit dd206d9ee43bde3827a5e49cd57080e51c2d8a67
Author: John Goerzen <jgoerzen at complete.org>
Date: Fri Oct 8 09:01:03 2004 +0100
Split out Simple handler
Keywords:
(jgoerzen at complete.org--projects/missingh--head--1.0--patch-50)
diff --git a/ChangeLog b/ChangeLog
index 5fb5bd6..d5626a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,21 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--1.0
#
+2004-10-08 03:01:03 GMT John Goerzen <jgoerzen at complete.org> patch-50
+
+ Summary:
+ Split out Simple handler
+ Revision:
+ missingh--head--1.0--patch-50
+
+
+ new files:
+ libsrc/MissingH/Logging/Handler/Simple.hs
+
+ modified files:
+ ChangeLog libsrc/MissingH/Logging/Handler.hs
+
+
2004-10-07 21:45:53 GMT John Goerzen <jgoerzen at complete.org> patch-49
Summary:
diff --git a/libsrc/MissingH/Logging/Handler.hs b/libsrc/MissingH/Logging/Handler.hs
index 058ee1b..9e3a723 100644
--- a/libsrc/MissingH/Logging/Handler.hs
+++ b/libsrc/MissingH/Logging/Handler.hs
@@ -16,15 +16,16 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
-{- | Definition of log handlers
+{- | Definition of log handler support
+
+For some handlers, check out "MissingH.Logging.Handler.Simple" and
+"MissingH.Logging.Handler.Syslog".
Written by John Goerzen, jgoerzen\@complete.org
-}
module MissingH.Logging.Handler(-- * Basic Types
- LogHandler(..),
- -- * Simple Handlers
- streamHandler, fileHandler
+ LogHandler(..)
) where
import MissingH.Logging
import IO
@@ -54,37 +55,3 @@ class LogHandler a where
-- any open files, etc.
close :: a -> IO ()
-
-data GenericHandler a = GenericHandler {priority :: Priority,
- privData :: a,
- writeFunc :: a -> String -> IO (),
- closeFunc :: a -> IO () }
-
-instance LogHandler (GenericHandler a) where
- setLevel sh p = sh{priority = p}
- getLevel sh = priority sh
- emit sh lr = (writeFunc sh) (privData sh) (snd lr)
- close sh = (closeFunc sh) (privData sh)
-
-{- | Create a stream log handler. Log messages sent to this handler will
- be sent to the stream used initially. Note that the 'close' method
- will have no effect on stream handlers; it does not actually close
- the underlying stream. -}
-
-streamHandler :: Handle -> Priority -> IO (GenericHandler Handle)
-streamHandler h pri =
- return (GenericHandler {priority = pri,
- privData = h,
- writeFunc = hPutStrLn,
- closeFunc = \x -> return ()})
-
-{- | Create a file log handler. Log messages sent to this handler
- will be sent to the filename specified, which will be opened
- in Append mode. Calling close on the handler will close the file.
- -}
-
-fileHandler :: FilePath -> Priority -> IO (GenericHandler Handle)
-fileHandler fp pri = do
- h <- openFile fp AppendMode
- sh <- streamHandler h pri
- return (sh{closeFunc = hClose})
diff --git a/libsrc/MissingH/Logging/Handler.hs b/libsrc/MissingH/Logging/Handler/Simple.hs
similarity index 60%
copy from libsrc/MissingH/Logging/Handler.hs
copy to libsrc/MissingH/Logging/Handler/Simple.hs
index 058ee1b..877ce03 100644
--- a/libsrc/MissingH/Logging/Handler.hs
+++ b/libsrc/MissingH/Logging/Handler/Simple.hs
@@ -1,4 +1,4 @@
-{- arch-tag: Log handlers main definition
+{- arch-tag: Simple log handlers
Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
@@ -16,45 +16,19 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
-{- | Definition of log handlers
+{- | Simple log handlers
Written by John Goerzen, jgoerzen\@complete.org
-}
-module MissingH.Logging.Handler(-- * Basic Types
- LogHandler(..),
- -- * Simple Handlers
- streamHandler, fileHandler
- ) where
+module MissingH.Logging.Handler.Simple(streamHandler, fileHandler)
+ where
+
import MissingH.Logging
+import MissingH.Logging.Handler
import IO
-{- | This is the base class for the various log handlers. They should
-all adhere to this class. -}
-
-class LogHandler a where
- -- | Sets the log level. 'handle' will drop
- -- items beneath this level.
- setLevel :: a -> Priority -> a
- -- | Gets the current level.
- getLevel :: a -> Priority
- -- | Logs an event if it meets the requirements
- -- given by the most recent call to 'setLevel'.
- handle :: a -> LogRecord -> IO ()
-
- handle h (pri, msg) =
- if pri >= (getLevel h)
- then emit h (pri, msg)
- else return ()
- -- | Forces an event to be logged regardless of
- -- the configured level.
- emit :: a -> LogRecord -> IO ()
- -- | Closes the logging system, causing it to close
- -- any open files, etc.
- close :: a -> IO ()
-
-
data GenericHandler a = GenericHandler {priority :: Priority,
privData :: a,
writeFunc :: a -> String -> IO (),
@@ -80,7 +54,7 @@ streamHandler h pri =
{- | Create a file log handler. Log messages sent to this handler
will be sent to the filename specified, which will be opened
- in Append mode. Calling close on the handler will close the file.
+ in Append mode. Calling 'close' on the handler will close the file.
-}
fileHandler :: FilePath -> Priority -> IO (GenericHandler Handle)
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list