Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.minLevel = opts.minLevel;
this.replacer = opts.replacer;
this.inactivityTimeout = opts.inactivityTimeout || defaults.inactivityTimeout;
this.timestamp = opts.timestamp;
this.withLevel = 'withLevel' in opts ? opts.withLevel : true;
this.withStack = opts.withStack;
this[$secure] = secure;
this[$reconnectInitialDelay] = opts.reconnectInitialDelay || defaults.reconnectInitialDelay;
this[$reconnectMaxDelay] = opts.reconnectMaxDelay || defaults.reconnectMaxDelay;
this[$reconnectBackoffStrategy] = opts.reconnectBackoffStrategy || defaults.reconnectBackoffStrategy;
this.debugEnabled = opts.debug || false;
if (!this.debugEnabled) {
//if there is no debug set, empty logger should be used
this.debugLogger = { log: () => { } };
} else {
this.debugLogger = (opts.debugLogger && opts.debugLogger.log) ? opts.debugLogger : defaults.debugLogger;
}
this[$reconnect] = reconnect_core(function () {
var connection;
if (secure) {
connection = tls.connect.apply(tls, arguments, () => {
if (!connection.authorized) {
this.debugLogger.log("Secure connection -TLS- is not authorized.");
const errMsg = connection.authorizationError;
this.emit(new LogentriesError(text.authError(errMsg)));
} else if (tls && tls.CleartextStream && connection instanceof tls.CleartextStream) {
this.emit('connect');
}
});
} else {
connection = net.connect.apply(null, arguments);