Created
October 31, 2022 16:00
-
-
Save maxwofford/a7858fb027200c2ec0873d42a7113ae1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { readLines } from "https://deno.land/[email protected]/io/buffer.ts"; | |
async function main() { | |
for await (const line of readLines(Deno.stdin)) { | |
let parts = line.split(" "); | |
if (parts.length == 14) { | |
let timestamp = new Date(parts[0]).getTime() / 1000; | |
let ip = parts[7].replace("fwd=", "").replace(/"/g, ""); | |
let request = parts[4].replace("path=", "").replace(/"/g, ""); | |
let host = parts[5].replace("host=", "").replace(/"/g, ""); | |
let dyno = parts[8].replace("dyno=", "").replace(/"/g, ""); | |
let status = parts[11].replace("status=", ""); | |
let size = parts[12].replace("bytes=", ""); | |
console.log( | |
`${timestamp}|${ip}|${request}|${status}|${size}|||||${host}|${dyno}`, | |
); | |
} | |
} | |
} | |
console.log("reading lines from stdin"); | |
main(); | |
// heroku logs --tail --ps router -a api2-hackclub | deno run ./heroku-to-clf.js | logstalgia - --sync |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment