Dear all
the runnable example code is as blow
===================================================================
import Conduit
import Text.Regex (matchRegex,mkRegex,Regex)
loghead = mkRegex "^([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3} )"
-- "2015-01-25 00:04:18,840"
logMerge::Regex->String->String->(String,[String])
logMerge logregex str accum =
case matchRegex logregex str of
Just _ -> (str,[(accum++"\n")])
Nothing -> case null accum of
True -> (str,[])
False -> (accum ++ "<br>" ++ str,[])
runMerge::String->String->IO ()
runMerge infile outfile =
runResourceT $ sourceFile infile $= linesUnboundedC $= concatMapAccumC (logMerge loghead ) "" $$ sinkFile outfile
================================================================
the example input file is
---------
2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: toString() = null
2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | codsexception.getErrorCode(): toString()
{
errorCode = "UNEXPECTED_PROBLEM"
severity = ""
}
2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | |
2015-01-25 00:03:45,331 | DEBUG | WebContainer : 20 | |
---------
the expected output is
---------
2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: toString() = null
2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | codsexception.getErrorCode(): toString() <br>{<br> errorCode =<br>"UNEXPECTED_PROBLEM"<br> severity = ""<br>}
2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | |
2015-01-25 00:03:45,331 | DEBUG | WebContainer : 20 | |
---------
the actual output is blow, missing the last line of log
---------
2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: toString() = null
2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | codsexception.getErrorCode(): toString() <br>{<br> errorCode =<br>"UNEXPECTED_PROBLEM"<br> severity = ""<br>}
2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | |
---------
Thanks
I'm afraid I doon't follow what it meant by the stream here. Could you provide a complete, runnable example and indicate what the expected and actual output are?