Skip to content

Commit

Permalink
Merge pull request #11 from gemini-testing/fix/add-debug
Browse files Browse the repository at this point in the history
fix(logging): do not log errors by default
  • Loading branch information
Alexander Tikvach authored Sep 17, 2021
2 parents 6d1b9bd + 3cc1346 commit 89e61a9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
24 changes: 16 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"dependencies": {
"bluebird": "^3.7.2",
"debug": "^4.3.2",
"fs-extra": "^10.0.0",
"gemini-configparser": "^1.1.0",
"hermione-profiler-ui": "^0.0.4",
Expand All @@ -35,6 +36,7 @@
},
"devDependencies": {
"@types/bluebird": "^3.5.36",
"@types/debug": "^4.1.7",
"@types/fs-extra": "^9.0.12",
"@types/jest": "^26.0.24",
"@types/lodash": "^4.14.171",
Expand Down
4 changes: 4 additions & 0 deletions src/debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import debug from 'debug';

export const createDebug = (namespace: string) =>
debug(`hermione-plugins-profiler:${namespace}`);
5 changes: 4 additions & 1 deletion src/parse-plugin-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import _ from 'lodash';
import * as stackTrace from 'stack-trace';
import { StackFrame } from 'stack-trace';

import { createDebug } from './debug';

const UNKNOWN_PLUGIN_NAME = 'UNKNOWN_PLUGIN';
const debug = createDebug('parse-plugin-name');

const findFrameWithPluginName = (
frames: StackFrame[]
Expand All @@ -23,7 +26,7 @@ const findFrameWithPluginName = (

export function parsePluginName(error: Error): string {
const logWarn = () =>
console.warn(
debug(
`Unable to parse plugin name from stack: ${error.stack}`
);
const traceFrames = stackTrace.parse(error);
Expand Down

0 comments on commit 89e61a9

Please sign in to comment.