Skip to content

Commit

Permalink
Refactor logging to avoid use of URLSearchParams.
Browse files Browse the repository at this point in the history
The logic path was hitting URLSearchParams initialization in older
Node.js versions that don't have that global. Removing since it's not
needed.
  • Loading branch information
davidlehn committed Jan 11, 2022
1 parent 50a20ec commit 2f3820a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,8 +2,9 @@ Forge ChangeLog
===============

### Fixed
- [tests] Load entire module to improve top-level testing and coverage
- [tests]: Load entire module to improve top-level testing and coverage
reporting.
- [log]: Refactor logging setup to avoid use of `URLSearchParams`.

## 1.2.0 - 2022-01-07

Expand Down
13 changes: 5 additions & 8 deletions lib/log.js
Expand Up @@ -286,7 +286,7 @@ if(typeof(console) !== 'undefined' && 'log' in console) {
}

/*
* Check for logging control query vars.
* Check for logging control query vars in current URL.
*
* console.level=<level-name>
* Set's the console log level by name. Useful to override defaults and
Expand All @@ -297,13 +297,10 @@ if(typeof(console) !== 'undefined' && 'log' in console) {
* after console.level is processed. Useful to force a level of verbosity
* that could otherwise be limited by a user config.
*/
if(sConsoleLogger !== null) {
var query;
if(typeof window !== 'undefined' && window.location) {
query = new URL(window.location.href).searchParams;
} else {
query = new URLSearchParams();
}
if(sConsoleLogger !== null &&
typeof window !== 'undefined' && window.location
) {
var query = new URL(window.location.href).searchParams;
if(query.has('console.level')) {
// set with last value
forge.log.setLevel(
Expand Down

0 comments on commit 2f3820a

Please sign in to comment.