[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:43:19 UTC 2010
The following commit has been merged in the master branch:
commit 22101002bbae22240164fc16a9757959c3cdb084
Author: John Goerzen <jgoerzen at complete.org>
Date: Thu Oct 7 22:12:35 2004 +0100
Added initial logging infrastructure
Keywords:
(jgoerzen at complete.org--projects/missingh--head--1.0--patch-43)
diff --git a/ChangeLog b/ChangeLog
index fb49bfa..3386d08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,26 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--1.0
#
+2004-10-07 16:12:35 GMT John Goerzen <jgoerzen at complete.org> patch-43
+
+ Summary:
+ Added initial logging infrastructure
+ Revision:
+ missingh--head--1.0--patch-43
+
+
+ new files:
+ libsrc/MissingH/Logging.hs
+ libsrc/MissingH/Logging/.arch-ids/=id
+ libsrc/MissingH/Logging/Handler.hs
+
+ modified files:
+ ChangeLog Makefile {arch}/=tagging-method
+
+ new directories:
+ libsrc/MissingH/Logging libsrc/MissingH/Logging/.arch-ids
+
+
2004-10-07 02:47:38 GMT John Goerzen <jgoerzen at complete.org> patch-42
Summary:
diff --git a/Makefile b/Makefile
index d1b0f13..e5778c2 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-SOURCES := $(wildcard libsrc/MissingH/*.hs) $(wildcard libsrc/MissingH/*/*.hs)
+SOURCES := $(wildcard libsrc/MissingH/*.hs) \
+ $(wildcard libsrc/MissingH/*/*.hs) \
+ $(wildcard libsrc/MissingH/*/*/*.hs)
OBJS := $(SOURCES:.hs=.o)
all: libmissingH.a
diff --git a/libsrc/MissingH/Logging.hs b/libsrc/MissingH/Logging.hs
new file mode 100644
index 0000000..b96fc22
--- /dev/null
+++ b/libsrc/MissingH/Logging.hs
@@ -0,0 +1,49 @@
+{- arch-tag: Logging Main Definition
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- | Basic logging types
+
+Written by John Goerzen, jgoerzen\@complete.org
+
+This module defines basic types used for logging.
+
+-}
+
+module MissingH.Logging(Priority(..),
+ LogRecord)
+ where
+
+{- | Priorities are used to define how important a log messgae is.
+Users can filter log messages based on priorities.
+
+These have their roots on the traditional syslog system. The standard
+definitions are given below, but you are free to interpret them however you
+like. They are listed here in descending importance order.
+-}
+
+data Priority = EMERG -- ^ System is unusable
+ | ALERT -- ^ Take immediate action
+ | CRITICAL -- ^ Severe situations
+ | ERROR -- ^ General Errors
+ | WARNING -- ^ General Warnings
+ | NOTICE -- ^ Normal runtime conditions
+ | INFO -- ^ Information
+ | DEBUG -- ^ Debug messages
+
+type LogRecord = (Priority, String)
+
diff --git a/libsrc/MissingH/Logging/Handler.hs b/libsrc/MissingH/Logging/Handler.hs
new file mode 100644
index 0000000..fc6d4cf
--- /dev/null
+++ b/libsrc/MissingH/Logging/Handler.hs
@@ -0,0 +1,67 @@
+{- arch-tag: Log handlers main definition
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+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
+
+Written by John Goerzen, jgoerzen\@complete.org
+n-}
+
+module MissingH.Logging.Handler(-- * Basic Types
+ LogHandler(..),
+ -- * Simple Handlers
+ newStreamHandler, TStreamH
+ ) where
+import MissingH.Logging
+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 ()
+ -- | 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 ()
+
+
+-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+-- Stream handler
+-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+data TStreamH = TStreamH (Handle, Priority)
+
+instance LogHandler TStreamH where
+ setLevel (TStreamH (h, pri)) newpri = TStreamH (h, newpri)
+ getLevel (TStreamH (h, pri)) = pri
+ handle (TStreamH (h, pri)) rec = return ()
+ emit (TStreamH(h, pri)) rec = return ()
+ close _ = return ()
+
+newStreamHandler :: Handle -> Priority -> TStreamH
+newStreamHandler h pri = TStreamH (h, pri)
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list