mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-04 08:37:30 +00:00
store: match late credit logs that start mid-line
This commit is contained in:
1 parent
cc9b8b90f7
commit
0387807c6e
1 file changed
+11
-2
@@ -216,9 +216,18 @@ rateCalls Late {lStub} = length . filter isRate <$> stubCalls lStub
|
||||
lateWaitOf :: DBStore -> Text -> IO (Maybe LateWait)
|
||||
lateWaitOf st r = withTransaction st $ \db -> lateWait db (invOf r)
|
||||
|
||||
-- | A log line of the level holding the text.
|
||||
-- | A log record of the level holding the text.
|
||||
logged :: Text -> Text -> Text -> Bool
|
||||
logged level needle = any (\ln -> ("[" <> level) `T.isPrefixOf` ln && needle `T.isInfixOf` ln) . T.lines
|
||||
logged level needle = any (\r -> ("[" <> level <> " ") `T.isPrefixOf` r && needle `T.isInfixOf` r) . concatMap logRecords . T.lines
|
||||
|
||||
-- | Specs running alongside log to the same stderr, so a record can start mid-line, after another's text and before its newline.
|
||||
logRecords :: Text -> [Text]
|
||||
logRecords ln = foldl (\parts header -> concatMap (splitBefore header) parts) [ln] ["[INFO ", "[WARN ", "[ERROR "]
|
||||
where
|
||||
splitBefore :: Text -> Text -> [Text]
|
||||
splitBefore header part = case T.splitOn header part of
|
||||
first : rest -> first : map (header <>) rest
|
||||
[] -> []
|
||||
|
||||
count :: Text -> Text -> Int
|
||||
count needle = length . T.breakOnAll needle
|
||||
|
||||
Reference in new issue
Block a user