-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manage debug parameters with a
DebugUtil
helper (#852)
* Manage debug parameters with a `DebugUtil` helper This is mainly to collect all of the supported debug parameters into one place. Tired of having to hunt for them. * Need to init RLS for navigator tests now
- Loading branch information
Showing
5 changed files
with
54 additions
and
4 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 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,38 @@ | ||
import RequestLocalStorage from "./RequestLocalStorage"; | ||
import forEach from "lodash/forEach"; | ||
import map from "lodash/map"; | ||
import assign from "lodash/assign"; | ||
import pick from "lodash/pick"; | ||
|
||
const RLS = RequestLocalStorage.getNamespace(); | ||
|
||
// This module provides methods that expose values from the query string. | ||
// | ||
// So, for example, if you pass `?_debug_render_timeout=1000` then you can | ||
// call `DebugUtil.getRenderTimeout()` and receive `1000`. | ||
// | ||
// Additionally you may call `DebugUtil.getAllDebugValues()` to obtain an | ||
// object with all debug parameters extracted from the query string. | ||
// | ||
const DEBUG_PARAMS = { | ||
getRenderTimeout : "_debug_render_timeout", | ||
getOutputLogs : "_debug_output_logs", | ||
getLogLevel : "_react_server_log_level", | ||
getLogLevelMain : "_react_server_log_level_main", | ||
getLogLevelTime : "_react_server_log_level_time", | ||
getLogLevelGauge : "_react_server_log_level_gauge", | ||
}; | ||
|
||
const DebugUtil = { | ||
setRequest(req) { | ||
assign(RLS(), pick(req.getQuery(), map(DEBUG_PARAMS, v => v))); | ||
}, | ||
getAllDebugValues() { | ||
return assign({}, RLS()); | ||
}, | ||
}; | ||
|
||
// Make the methods. | ||
forEach(DEBUG_PARAMS, (param, method) => DebugUtil[method] = () => RLS()[param]); | ||
|
||
export default DebugUtil; |