MCPcopy Index your code
hub / github.com/skygragon/leetcode-cli / initLogLevel

Function initLogLevel

lib/cli.js:27–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27function initLogLevel() {
28 log.init();
29
30 let level = 'INFO';
31 if (process.argv.indexOf('-v') >= 0) level = 'DEBUG';
32 if (process.argv.indexOf('-vv') >= 0) level = 'TRACE';
33
34 // print HTTP details in TRACE
35 if (level === 'TRACE') {
36 const request = require('request');
37 request.debug = true;
38
39 console.error = _.wrap(console.error, function(func) {
40 let args = Array.from(arguments);
41 args.shift();
42
43 // FIXME: hack HTTP request log, hope no one else use it...
44 if (args.length > 0 && args[0].indexOf('REQUEST ') === 0) {
45 args = args.map((x) => h.printSafeHTTP(x));
46 log.trace.apply(log, args);
47 } else {
48 log.info.apply(log, args);
49 }
50 });
51 }
52
53 log.setLevel(level);
54}
55
56function initDir() {
57 file.init();

Callers 1

cli.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected