in src/main/scala/com/twitter/iago/server/ParrotServer.scala [233:253]
def getLog(offset: Long, length: Int, fileName: java.lang.String): Future[ParrotLog] = Future {
if (wandering(fileName))
throw new RuntimeException("can only reference files at the top of this sandbox")
val fl = new File(fileName)
val sz = fl.length()
// an offset of -1 means please position me near the end
val tail = 5000
val (theLen, theOffset) = if (offset == -1) (tail, sz - tail) else (length, offset)
val fr = new FileReader(fl)
val off = math.min(sz, math.max(0, theOffset))
fr.skip(off)
val len = math.max(0, math.min(theLen, math.min(Int.MaxValue.toLong, sz - off).toInt))
val buf = new Array[Char](len)
fr.read(buf)
fr.close()
ParrotLog(off, len, new String(buf))
}