MCPcopy
hub / github.com/mongodb/node-mongodb-native / main

Function main

etc/crawfish.mjs:16–97  ·  etc/crawfish.mjs::main

* @param args - program arguments

(args)

Source from the content-addressed store, hash-verified

14 * @param args - program arguments
15 */
16async function main(args) {
17 args = yargs(args)
18 .option(class="st">'l', {
19 alias: class="st">'log',
20 demandOption: true,
21 default: class="st">'./data/mongod.log', class="cm">// cluster_setup.sh default
22 describe: class="st">'The log you wish to filter',
23 type: class="st">'string'
24 })
25 .option(class="st">'f', {
26 alias: class="st">'filter',
27 demandOption: true,
28 default: class="st">'', class="cm">// No filter is still useful if you want to look at all tests
29 describe: class="st">'The test name filter, if none provided all test logs will be shown',
30 type: class="st">'string'
31 })
32 .option(class="st">'v', {
33 alias: class="st">'verbose',
34 demandOption: false,
35 describe: class="st">'Enable warnings about processing',
36 type: class="st">'boolean'
37 })
38 .help(class="st">'h')
39 .alias(class="st">'h', class="st">'help').epilog(`
40 - Some log processing is done:
41 - better date time format
42 - string interpolation
43 - class="st">'testName' property added
44 - Depends on an xunit file, should be left over from every test run
45
46 Examples:
47 ${chalk.green(class="st">'crawfish.mjs | jq -SC | less -R')}
48 - jq -SC will sort the keys and force color output
49 - less lets you page through and search logs
50
51 ${chalk.green(class="st">'crawfish.mjs | jq -Sc | code -')}
52 - jq -Sc will sort the keys and keep the logs one line (compact)
53 - Opens the output in vscode, good for searching!
54 `).argv;
55
56 warnings = !!args.verbose;
57 const logFile = args.log;
58 const testNameRegex = args.filter;
59
60 if (!existsSync(class="st">'xunit.xml')) {
61 console.error(class="st">'xunit.xml file not found, required for db log test filtering.');
62 process.exit(1);
63 }
64
65 const content = await readFile(class="st">'xunit.xml', { encoding: class="st">'utf8' });
66 const xunit = await parseStringPromise(content);
67
68 const tests = collectTests(xunit, testNameRegex);
69 if (warnings) console.error(`filtering log file ${logFile}`);
70
71 const logStream =
72 logFile === class="st">'-' ? process.stdin : createReadStream(logFile, { encoding: class="st">'utf8' });
73 const lineStream = createInterface({

Callers 1

crawfish.mjsFile · 0.70

Calls 9

interpolateMsgFunction · 0.85
friendlyDateFunction · 0.85
errorMethod · 0.80
logMethod · 0.80
collectTestsFunction · 0.70
mapMethod · 0.45
parseMethod · 0.45
pushMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected