File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ module LogAnalysis.Classifier
1313
1414import Universum
1515
16- import qualified Data.ByteString.Lazy as LBS
1716import qualified Data.Map.Strict as Map
1817import Data.Text (isInfixOf )
1918import Data.Text.Encoding.Error (ignore )
@@ -27,17 +26,17 @@ numberOfErrorText :: Int
2726numberOfErrorText = 3
2827
2928-- | Analyze each log file based on the knowlodgebases' data.
30- extractIssuesFromLogs :: (MonadCatch m ) => [LByteString ] -> Analysis -> m Analysis
29+ extractIssuesFromLogs :: (MonadCatch m ) => [ByteString ] -> Analysis -> m Analysis
3130extractIssuesFromLogs files analysis = do
3231 analysisResult <- foldlM runClassifiers analysis files
3332 filterAnalysis analysisResult
3433
3534-- | Run analysis on given file
36- runClassifiers :: (MonadCatch m ) => Analysis -> LByteString -> m Analysis
35+ runClassifiers :: (MonadCatch m ) => Analysis -> ByteString -> m Analysis
3736runClassifiers analysis logfile = do
3837 -- Force the evaluation of the whole file.
3938 strictLogfile <- catchAnyStrict (pure logfile) $ \ _ -> throwM LogReadException
40- pure . foldl' analyzeLine analysis . lines . decodeUtf8With ignore . LBS. toStrict $ strictLogfile
39+ pure . foldl' analyzeLine analysis . lines . decodeUtf8With ignore $ strictLogfile
4140 where
4241
4342 -- | A helpful utility function.
Original file line number Diff line number Diff line change @@ -6,16 +6,18 @@ module Util
66import Universum
77
88import qualified Codec.Archive.Zip as Zip
9+ import qualified Data.ByteString.Lazy as LBS
910import qualified Data.Map.Strict as Map
1011
1112import Exceptions (ZipFileExceptions (.. ))
1213
1314-- | Extract log file from given zip file
1415-- TODO(ks): What happens with the other files? We just ignore them?
15- extractLogsFromZip :: Int -> LByteString -> Either ZipFileExceptions [LByteString ]
16+ extractLogsFromZip :: Int -> LByteString -> Either ZipFileExceptions [ByteString ]
1617extractLogsFromZip numberOfFiles file = do
1718 zipMap <- readZip file -- Read File
18- let extractedLogs = Map. elems $ mTake numberOfFiles zipMap -- Extract selected logs
19+ let extractedLogs :: [ByteString ]
20+ extractedLogs = map LBS. toStrict . Map. elems . mTake numberOfFiles $ zipMap
1921 return extractedLogs
2022 where
2123 mTake :: Int -> Map k a -> Map k a
You can’t perform that action at this time.
0 commit comments