Skip to content

Commit

Permalink
Update utils/log_settings.js
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 committed Aug 8, 2023
1 parent 05ee135 commit eeb3770
Showing 1 changed file with 73 additions and 80 deletions.
153 changes: 73 additions & 80 deletions lib/utils/logger/log_settings.js
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();

0 comments on commit eeb3770

Please sign in to comment.