packages feed

hslogger-template 1.0.0 → 1.1.0

raw patch · 4 files changed

+40/−5 lines, 4 filessetup-changedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ System.Log.Logger.TH: deriveNamedLoggers :: String -> String -> [Priority] -> Q [Dec]

Files

Setup.hs view
@@ -8,6 +8,11 @@ main =     defaultMainWithHooks $ simpleUserHooks { runTests = runTests' }   where-    runTests' _ _ _ _ = do-        system "runhaskell -i./src src/test.hs"-        return ()+    runTests' _ _ _ _ =+        mapM_ runTest ["test.hs", "testNamed.hs"]+      where+        runTest fp = do+            putStrLn $ fp ++ ":"+            system $ "runhaskell -i./src src/" ++ fp+            putStrLn ""+            return ()
hslogger-template.cabal view
@@ -1,5 +1,5 @@ name:        hslogger-template-version:     1.0.0+version:     1.1.0 category:    Interfaces synopsis:    Automatic generation of hslogger functions description: Library for generating hslogger functions using Template Haskell.@@ -11,7 +11,7 @@ build-type:    Custom  extra-source-files:-  src/test.hs+  src/test.hs, src/testNamed.hs  library   hs-source-dirs:
src/System/Log/Logger/TH.hs view
@@ -5,6 +5,7 @@ module System.Log.Logger.TH   (     deriveLoggers+  , deriveNamedLoggers   )   where @@ -42,6 +43,10 @@ -- -- > Foo.Bar: hi there --+-- If the automatically determined module name would not be informative enough+-- (e.g., "Main"), @deriveNamedLoggers@ allows you to specify a different+-- message prefix.+-- -- Notes: -- --   * "System.Log.Logger" must be imported qualified, and the qualifier must@@ -58,6 +63,14 @@ deriveLoggers qualifier priorities =     fmap TH.loc_module TH.location >>= \moduleName ->       fmap concat (mapM (deriveLogger qualifier moduleName) priorities)++deriveNamedLoggers+  :: String          -- ^ Message prefix, e.g., "SomeProgram".+  -> String          -- ^ Must match qualifier on import of "System.Log.Logger".+  -> [HSL.Priority]  -- ^ List of priorities for which to generate logging functions.+  -> TH.Q [TH.Dec]+deriveNamedLoggers prefix qualifier priorities =+      fmap concat (mapM (deriveLogger qualifier prefix) priorities)  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
+ src/testNamed.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE TemplateHaskell #-}++module Main (main) where++import System.Log.Logger.TH (deriveNamedLoggers)+import qualified System.Log.Logger as HSL++$(deriveNamedLoggers "testNamed" "HSL" [HSL.DEBUG, HSL.INFO, HSL.NOTICE, HSL.WARNING, HSL.ERROR, HSL.CRITICAL, HSL.ALERT, HSL.EMERGENCY])++main :: IO ()+main = do+    HSL.updateGlobalLogger "testNamed" (HSL.setLevel HSL.DEBUG)+    mapM_ (\(f, fn, i) -> f (show i ++ " " ++ fn)) (zip3 functions functionNames numbers)+  where+    functions     = [debugM, infoM, noticeM, warningM, errorM, criticalM, alertM, emergencyM]+    functionNames = ["debugM", "infoM", "noticeM", "warningM", "errorM", "criticalM", "alertM", "emergencyM"]+    numbers       = [1..] :: [Integer]