Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "dbx-js-tools",
"private": true,
"workspaces": [
"packages/bson-bench"
"packages/bson-bench",
"packages/evergreen-timestamp-utils"
],
"devDependencies": {
"@tsconfig/node16": "^16.1.4",
Expand All @@ -28,4 +29,4 @@
"check:eslint": "ESLINT_USE_FLAT_CONFIG=false eslint -v && ESLINT_USE_FLAT_CONFIG=false eslint --max-warnings=0 --ext '.js,.ts,.mts' packages/**/src packages/**/test",
"fix:eslint": "npm run check:eslint -- --fix"
}
}
}
11 changes: 11 additions & 0 deletions packages/evergreen-timestamp-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# evergreen-timestamp-utils

A simple utility for stripping timestamps from evergreen logs.

## usage

(macos)

```bash
pbpaste | node index.mjs | pbcopy
```
45 changes: 45 additions & 0 deletions packages/evergreen-timestamp-utils/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env node

import { pipeline } from 'stream/promises';

async function* lines(generator) {
let data = '';

for await (const chunk of generator) {
data += chunk;
}

yield* data.split('\n');
}

async function* removeEmptyLines(generator) {
for await (const chunk of generator) {
if (chunk.length) yield chunk;
}
}

async function* removeTimestamp(generator) {
for await (const line of generator) {
const timestamp = /\[.*\](?<rest>.*)/;
const {
groups: { rest }
} = line.match(timestamp) ?? { groups: { rest: line } };
yield rest;
}
}

async function* addNewlines(generator) {
for await (const item of generator) {
yield item;
yield '\n';
}
}

await pipeline(
process.stdin,
lines,
removeEmptyLines,
removeTimestamp,
addNewlines,
process.stdout
);
15 changes: 15 additions & 0 deletions packages/evergreen-timestamp-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "evergreen-timestamp-utils",
"version": "0.0.1",
"description": "utility to strip timestamp from evergreen logs",
"private": true,
"main": "./index.mjs",
"scripts": {},
"engines": {
"node": ">=16.20.1",
"npm": ">=9.0.0"
},
"keywords": [],
"author": "The MongoDB NodeJS Team <[email protected]>",
"license": "Apache-2.0"
}