nuxeo 0.1.0.1 → 0.2.0.0
raw patch · 2 files changed
+23/−19 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Nuxeo.Log: data NuxeoTypeLog
- Nuxeo.Log: instance GHC.Classes.Eq Nuxeo.Log.NuxeoTypeLog
- Nuxeo.Log: instance GHC.Read.Read Nuxeo.Log.NuxeoTypeLog
- Nuxeo.Log: instance GHC.Show.Show Nuxeo.Log.NuxeoTypeLog
+ Nuxeo.Log: data NuxeoLogType
+ Nuxeo.Log: instance GHC.Classes.Eq Nuxeo.Log.NuxeoLogType
+ Nuxeo.Log: instance GHC.Read.Read Nuxeo.Log.NuxeoLogType
+ Nuxeo.Log: instance GHC.Show.Show Nuxeo.Log.NuxeoLogType
+ Nuxeo.Log: type NuxeoLogVerbose = Bool
- Nuxeo.Log: Debug :: NuxeoTypeLog
+ Nuxeo.Log: Debug :: NuxeoLogType
- Nuxeo.Log: Error :: NuxeoTypeLog
+ Nuxeo.Log: Error :: NuxeoLogType
- Nuxeo.Log: Info :: NuxeoTypeLog
+ Nuxeo.Log: Info :: NuxeoLogType
- Nuxeo.Log: NuxeoLogEntry :: LocalTime -> NuxeoTypeLog -> Text -> Text -> Text -> NuxeoLogEntry
+ Nuxeo.Log: NuxeoLogEntry :: LocalTime -> NuxeoLogType -> Text -> Text -> Text -> NuxeoLogEntry
- Nuxeo.Log: Warning :: NuxeoTypeLog
+ Nuxeo.Log: Warning :: NuxeoLogType
- Nuxeo.Log: [nuxeoLogEntryType] :: NuxeoLogEntry -> NuxeoTypeLog
+ Nuxeo.Log: [nuxeoLogEntryType] :: NuxeoLogEntry -> NuxeoLogType
- Nuxeo.Log: parseNuxeoLog :: Verbose -> FilePath -> IO NuxeoLog
+ Nuxeo.Log: parseNuxeoLog :: NuxeoLogVerbose -> FilePath -> IO NuxeoLog
Files
- nuxeo.cabal +1/−1
- src/Nuxeo/Log.hs +22/−18
nuxeo.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: nuxeo-version: 0.1.0.1+version: 0.2.0.0 synopsis: Nuxeo description: Nuxeo license: BSD3
src/Nuxeo/Log.hs view
@@ -1,7 +1,8 @@ {-# LANGUAGE OverloadedStrings #-} module Nuxeo.Log (- NuxeoTypeLog (..)+ NuxeoLogVerbose+ , NuxeoLogType (..) , NuxeoLogEntry (..) , parseNuxeoLog ) where@@ -15,13 +16,13 @@ import qualified Data.Text as T import Data.Time -type Verbose = Bool+type NuxeoLogVerbose = Bool -data NuxeoTypeLog = Debug | Error | Warning | Info deriving (Show, Read, Eq)+data NuxeoLogType = Debug | Error | Warning | Info deriving (Show, Read, Eq) data NuxeoLogEntry = NuxeoLogEntry { nuxeoLogEntryDthr :: LocalTime- , nuxeoLogEntryType :: NuxeoTypeLog+ , nuxeoLogEntryType :: NuxeoLogType , nuxeoLogEntrySection :: T.Text , nuxeoLogEntryAction :: T.Text , nuxeoLogEntryLog :: T.Text@@ -29,28 +30,31 @@ type NuxeoLog = [NuxeoLogEntry] --- |Parse Nuxeo server.log--- >logs <- parseNuxeoLog v "/opt/nuxeo-data/log/server.log"--- >filter (\l -> (nuxeoLogEntryType l == Error)--- > || (nuxeoLogEntryType l == Warning)) logs-parseNuxeoLog :: Verbose -> FilePath -> IO NuxeoLog+-- | Parse Nuxeo server.log+--+-- @+-- logs <- parseNuxeoLog v "/opt/nuxeo-data/log/server.log"+-- filter (\l -> (nuxeoLogEntryType l == Error)+-- || (nuxeoLogEntryType l == Warning)) logs+-- @+parseNuxeoLog :: NuxeoLogVerbose -> FilePath -> IO NuxeoLog parseNuxeoLog v logpath = runConduitRes $ sourceFile logpath .| sinkParser (nuxeoLogParser v) -nuxeoLogParser :: Verbose -> Parser NuxeoLog+nuxeoLogParser :: NuxeoLogVerbose -> Parser NuxeoLog nuxeoLogParser v = many $ (nuxeoLogEntryParser v <* endOfLine) -nuxeoLogEntryParser :: Verbose -> Parser NuxeoLogEntry+nuxeoLogEntryParser :: NuxeoLogVerbose -> Parser NuxeoLogEntry nuxeoLogEntryParser v = do- letime <- timeParser- letype <- space *> nuxeoTypeLogParser- section <- space *> nuxeoLogEntrySectionParser- action <- space *> nuxeoLogEntryActionParser- nuxeolog <- case v of+ ptime <- timeParser+ ptype <- space *> nuxeoTypeLogParser+ psection <- space *> nuxeoLogEntrySectionParser+ paction <- space *> nuxeoLogEntryActionParser+ pnuxeolog <- case v of True -> space *> manyTill' anyChar (try $ lookAhead $ char '\n' *> timeParser) False -> space *> manyTill' anyChar (try $ lookAhead $ char '\n')- return $ NuxeoLogEntry letime letype section action (T.pack nuxeolog)+ return $ NuxeoLogEntry ptime ptype psection paction (T.pack pnuxeolog) -nuxeoTypeLogParser :: Parser NuxeoTypeLog+nuxeoTypeLogParser :: Parser NuxeoLogType nuxeoTypeLogParser = (string "ERROR" *> return Error) <|> (string "DEBUG" *> return Debug) <|> (string "WARN" *> return Warning)