-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
73 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,96 @@ | ||
const lodashClone = require('lodash.clone'); | ||
|
||
const Settings = { | ||
outputEnabled: true, | ||
showResponseHeaders: false, | ||
showRequestData: { | ||
enabled: true, | ||
trimLongScripts: true | ||
}, | ||
detailedOutput: true, | ||
disableErrorLog: false, | ||
log_timestamp: false, | ||
timestamp_format: null, | ||
enabled: true | ||
}; | ||
|
||
module.exports = new (function() { | ||
const logSettings = lodashClone(Settings, true); | ||
|
||
class LogSettings { | ||
get outputEnabled() { | ||
return logSettings.outputEnabled; | ||
} | ||
class LogSettings { | ||
constructor() { | ||
this.__outputEnabled = true; | ||
this.__showResponseHeaders = false; | ||
this.__showRequestData = { | ||
enabled: true, | ||
trimLongScripts: true | ||
}, | ||
this.__detailedOutput = true; | ||
this.__disableErrorLog = false; | ||
this.__log_timestamp = false; | ||
this.__timestamp_format = null; | ||
this.__enabled = true; | ||
this.__htmlReporterEnabled = false; | ||
} | ||
|
||
get detailedOutput() { | ||
return logSettings.detailedOutput; | ||
} | ||
get outputEnabled() { | ||
return this.__outputEnabled; | ||
} | ||
|
||
get showRequestData() { | ||
return logSettings.showRequestData; | ||
set outputEnabled(value) { | ||
if (typeof value == 'undefined') { | ||
value = true; | ||
} | ||
|
||
get enabled() { | ||
return logSettings.enabled; | ||
} | ||
this.__outputEnabled = value; | ||
} | ||
|
||
get showResponseHeaders() { | ||
return logSettings.showResponseHeaders; | ||
} | ||
get showResponseHeaders() { | ||
return this.__showResponseHeaders; | ||
} | ||
|
||
get timestampFormat() { | ||
return logSettings.timestamp_format; | ||
} | ||
get showRequestData() { | ||
return this.__showRequestData; | ||
} | ||
|
||
set outputEnabled(value) { | ||
if (typeof value == 'undefined') { | ||
value = true; | ||
} | ||
get detailedOutput() { | ||
return this.__detailedOutput; | ||
} | ||
|
||
logSettings.outputEnabled = value; | ||
} | ||
set detailedOutput(value) { | ||
this.__detailedOutput = value; | ||
} | ||
|
||
set detailedOutput(value) { | ||
logSettings.detailedOutput = value; | ||
set disableErrorLog(value) { | ||
if (typeof value == 'undefined') { | ||
value = true; | ||
} | ||
|
||
set disableErrorLog(value) { | ||
if (typeof value == 'undefined') { | ||
value = true; | ||
} | ||
|
||
logSettings.disableErrorLog = value; | ||
} | ||
this.__disableErrorLog = value; | ||
} | ||
|
||
set htmlReporterEnabled(value) { | ||
logSettings.htmlReporterEnabled = value; | ||
} | ||
get timestampFormat() { | ||
return this.__timestamp_format; | ||
} | ||
|
||
get htmlReporterEnabled() { | ||
return logSettings.htmlReporterEnabled; | ||
} | ||
get enabled() { | ||
return this.__enabled; | ||
} | ||
|
||
isLogTimestamp() { | ||
return logSettings.log_timestamp; | ||
} | ||
get htmlReporterEnabled() { | ||
return this.__htmlReporterEnabled; | ||
} | ||
|
||
isErrorLogEnabled() { | ||
return !logSettings.disableErrorLog; | ||
} | ||
set htmlReporterEnabled(value) { | ||
this.__htmlReporterEnabled = value; | ||
} | ||
|
||
disable() { | ||
logSettings.enabled = false; | ||
} | ||
isLogTimestamp() { | ||
return this.__log_timestamp; | ||
} | ||
|
||
enable() { | ||
logSettings.enabled = true; | ||
} | ||
isErrorLogEnabled() { | ||
return !this.__disableErrorLog; | ||
} | ||
|
||
setLogTimestamp(val, format) { | ||
logSettings.log_timestamp = val; | ||
logSettings.timestamp_format = format; | ||
} | ||
disable() { | ||
this.__enabled = false; | ||
} | ||
|
||
setHttpLogOptions({showRequestData, showResponseHeaders}) { | ||
logSettings.showRequestData = showRequestData; | ||
logSettings.showResponseHeaders = showResponseHeaders; | ||
} | ||
enable() { | ||
this.__enabled = true; | ||
} | ||
|
||
setLogTimestamp(val, format) { | ||
this.__log_timestamp = val; | ||
this.__timestamp_format = format; | ||
} | ||
|
||
setHttpLogOptions({showRequestData, showResponseHeaders}) { | ||
this.__showRequestData = showRequestData; | ||
this.__showResponseHeaders = showResponseHeaders; | ||
} | ||
} | ||
|
||
return new LogSettings(); | ||
})(); | ||
module.exports = new LogSettings(); |