hslogger-reader 1.0.1 → 1.0.2
raw patch · 5 files changed
+43/−33 lines, 5 filesdep ~attoparsecdep ~optparse-applicativedep ~timePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: attoparsec, optparse-applicative, time
API changes (from Hackage documentation)
Files
- changelog +0/−5
- changelog.md +10/−0
- hslogger-reader.cabal +7/−6
- src-exe/filter-logs/Arguments.hs +10/−1
- src-exe/filter-logs/Main.hs +16/−21
− changelog
@@ -1,5 +0,0 @@-1.0.1--------* Supporting base == 4.8.* and time == 1.5.*, and providing an- `old-locale' flag in order to build with time < 1.5.
+ changelog.md view
@@ -0,0 +1,10 @@+# 1.0.2 - 24-Oct-2016++* Now skipping unparsable lines in `filter-logs` by default. Previous+ behaviour may be recovered with --no-continue option;+* Supporting GHC 8.0.1 and [lts-7.0](https://www.stackage.org/lts-7.0).++# 1.0.1++* Supporting base == 4.8.* and time == 1.5.*, and providing an+ `old-locale' flag in order to build with time < 1.5.
hslogger-reader.cabal view
@@ -1,5 +1,5 @@ name: hslogger-reader-version: 1.0.1+version: 1.0.2 synopsis: Parsing hslogger-produced logs. description: hslogger-reader provides a function to generate a parser for@@ -16,7 +16,7 @@ bug-reports: http://github.com/prophet-on-that/hslogger-reader/issues cabal-version: >=1.10 category: Interfaces, Parsing-Extra-Source-Files: changelog +Extra-Source-Files: changelog.md Flag old-locale Description: When enabled, use time < 1.5@@ -31,7 +31,7 @@ Haskell2010 build-depends: base >= 4.7 && < 5- , attoparsec == 0.12.*+ , attoparsec >= 0.12 && < 0.14 , text == 1.2.* , hslogger == 1.2.* if flag(old-locale)@@ -40,7 +40,7 @@ , old-locale else build-depends: - time == 1.5.*+ time >= 1.5 && < 1.7 ghc-options: -W executable profiling@@ -61,6 +61,7 @@ Main.hs other-modules: Arguments+ , Paths_hslogger_reader default-language: Haskell2010 build-depends: base@@ -69,13 +70,13 @@ , attoparsec , hslogger , text-icu == 0.7.*- , optparse-applicative == 0.11.*+ , optparse-applicative >= 0.11 && < 0.13 if flag(old-locale) build-depends: time == 1.4.* , old-locale else build-depends: - time == 1.5.*+ time >= 1.5 && < 1.7 ghc-options: -W
src-exe/filter-logs/Arguments.hs view
@@ -5,6 +5,8 @@ , opts ) where +import Paths_hslogger_reader (version)+import Data.Version (showVersion) import Options.Applicative import System.Log.Logger import qualified Data.Text as T@@ -25,6 +27,7 @@ , format :: T.Text , pid :: Maybe Int , tid :: Maybe Int+ , noContinue :: Bool , logFile :: FilePath } @@ -97,12 +100,18 @@ <> help "Assert logging thread." ) )+ <*> ( switch $+ ( long "no-continue"+ <> help "Do not skip unparsable lines, but fail with error message."+ )+ ) <*> ( strArgument $ metavar "FILE" ) opts = info (helper <*> parseArgs)- ( header "Filter hslogger-produced log files."+ ( header ("filter-logs version " <> showVersion version)+ <> progDesc "Filter hslogger-produced log files. Unparsable lines will be skipped. This behaviour can be overridden with the --no-continue option." <> fullDesc <> footer "Limitations: logs must use hslogger's default time format `yyyy-mm-ddThh:mm:ssZ' and logger names must not include whitespace." )
src-exe/filter-logs/Main.hs view
@@ -4,11 +4,13 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE RecordWildCards #-} -module Main where+module Main+ ( main+ ) where import Arguments- import Options.Applicative (execParser) import Prelude hiding (takeWhile) import System.Log.Reader@@ -26,37 +28,30 @@ import Data.Monoid main = do- arguments <- execParser opts-- regex'' <- case pattern arguments of+ Arguments {..} <- execParser opts+ regex'' <- case pattern of Nothing -> return Nothing Just pattern' -> do let regexOptions- = if insensitive arguments+ = if insensitive then [CaseInsensitive] else [] either (throwIO . RegexError) (return . return) $ regex' regexOptions pattern'- messageParser <- either (throwIO . ParserError) return $ logMessageParser (format arguments) loggerNameParser+ messageParser <- either (throwIO . ParserError) return $ logMessageParser format loggerNameParser - lts <- fmap L.lines . L.readFile . logFile $ arguments+ lts <- fmap L.lines . L.readFile $ logFile forM lts $ \lt -> do- lm <- either (const $ throwIO (MessageParseError lt)) return . eitherResult . parse messageParser $ lt- let- pred- = filterLogMessage- (lowerPrio arguments)- (upperPrio arguments)- (lowerTime arguments)- (upperTime arguments)- (pid arguments)- (tid arguments)- regex''- - when (pred lm) $ L.putStrLn lt+ case maybeResult $ parse messageParser lt of+ Nothing ->+ when noContinue $+ throwIO $ MessageParseError lt+ Just lm ->+ when (filterLogMessage lowerPrio upperPrio lowerTime upperTime pid tid regex'' lm) $+ L.putStrLn lt where loggerNameParser = takeTill isHorizontalSpace