Skip to content

Instantly share code, notes, and snippets.

@robotmay
Created November 29, 2019 15:47
Show Gist options
  • Save robotmay/2c93c59f2e51b7c5da7e011e4c21e37d to your computer and use it in GitHub Desktop.
Save robotmay/2c93c59f2e51b7c5da7e011e4c21e37d to your computer and use it in GitHub Desktop.
83 <40>1 2012-11-30T06:45:29+00:00 host app web.3 - State changed from starting to up
119 <40>1 2012-11-30T06:45:26+00:00 host app web.3 - Starting process with command `bundle exec rackup config.ru -p 24405`
data Log = Log
{ size :: Int
, time :: Text
, message :: Text
} deriving (Eq, Show)
pLog :: Parser Log
pLog = do
notFollowedBy eof
size <- L.decimal <?> "size"
void (char ' ')
void (char '<')
void (some alphaNumChar)
void (char '>')
void alphaNumChar
void (char ' ')
time <- Text.pack <$> someTill anySingle (char ' ') <?> "time"
message <- takeRest <?> "message"
return Log {..}
pLogs :: Parser (Vector Log)
pLogs = do
logs <- sepBy1 pLog eol
eof
return $! Vector.fromList logs
Right [Log {size = 83, time = "2012-11-30T06:45:29+00:00", message = "host app web.3 - State changed from starting to up\n119 <40>1 2012-11-30T06:45:26+00:00 host app web.3 - Starting process with command `bundle exec rackup config.ru -p 24405`"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment