Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #503 from wheresrhys/debug-logs-1
Debug logs 1
- Loading branch information
Showing
13 changed files
with
337 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: Debugging | ||
position: 8 | ||
content_markdown: |- | ||
The first step when debugging tests should be to run with the environment variable `DEBUG=fetch-mock*`. This will output additional logs for debugging purposes. | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const debug = require('debug'); | ||
|
||
let debugFunc; | ||
let phase = 'default'; | ||
let namespace = ''; | ||
const newDebug = () => { | ||
debugFunc = namespace | ||
? debug(`fetch-mock:${phase}:${namespace}`) | ||
: debug(`fetch-mock:${phase}`); | ||
}; | ||
|
||
const newDebugSandbox = ns => debug(`fetch-mock:${phase}:${ns}`); | ||
|
||
newDebug(); | ||
|
||
module.exports = { | ||
debug: (...args) => { | ||
debugFunc(...args); | ||
}, | ||
setDebugNamespace: str => { | ||
namespace = str; | ||
newDebug(); | ||
}, | ||
setDebugPhase: str => { | ||
phase = str || 'default'; | ||
newDebug(); | ||
}, | ||
getDebug: namespace => newDebugSandbox(namespace) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.