Skip to content

Instantly share code, notes, and snippets.

@nicmarti
Created June 21, 2012 21:16
Show Gist options
  • Save nicmarti/2968582 to your computer and use it in GitHub Desktop.
Save nicmarti/2968582 to your computer and use it in GitHub Desktop.
def getJobsSinceWithPattern(someday: DateTime, msgPattern: String): List[Log] = DB.withConnection{
implicit c=>
val sql = SQL("""|SELECT log_date, category, level, message, error, source FROM logs
|WHERE log_date >={day}
|AND message like {msg}
""".stripMargin)
.on("day" -> someday.toString("yyyy-MM-dd")).on("msg" -> msgPattern)
val listParsed=sql.as(date("log_date") ~ str("category") ~ str("level") ~ str("message") ~ get[Option[String]]("error") ~ str("source") map flatten *)
listParsed.map{ it=> Log(new DateTime(it._1), it._2, it._3, it._4, it._5, it._6) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment