Skip to content

Commit

Permalink
chore(scripts): make scripts/logserver.js output pipeable (#5089)
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson authored Nov 10, 2023
1 parent 366b7af commit cb6335e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/logserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
// env HADRON_METRICS_SEGMENT_API_KEY='ignore' HADRON_METRICS_SEGMENT_HOST='http://localhost:8000' npm start
const http = require('http');

function write(payload) {
if (process.stdout.isTTY) {
console.dir(payload, { depth: Infinity });
} else {
process.stdout.write(JSON.stringify(payload) + '\n');
}
}
http
.createServer((req, res) => {
let body = '';
Expand All @@ -17,7 +24,8 @@ http
} catch {
//
}
console.dir({ headers: req.headers, body }, { depth: Infinity });

write({ headers: req.headers, body });
res.writeHead(200);
res.end('Ok\n');
});
Expand Down

0 comments on commit cb6335e

Please sign in to comment.