Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const requestEndTime = new Date();
const requestCompletionTime = requestEndTime.getTime() - this.requestStartTime.getTime();
const operationDuration = requestEndTime.getTime() - this.operationStartTime.getTime();
let currentLevel: HttpPipelineLogLevel = HttpPipelineLogLevel.INFO;
let logMessage: string = "";
if (this.shouldLog(HttpPipelineLogLevel.INFO)) {
// Assume success and default to informational logging.
logMessage = "Successfully Received Response. ";
}
// If the response took too long, we'll upgrade to warning.
if (requestCompletionTime >= this.loggingOptions.logWarningIfTryOverThreshold) {
// Log a warning if the try duration exceeded the specified threshold.
if (this.shouldLog(HttpPipelineLogLevel.WARNING)) {
currentLevel = HttpPipelineLogLevel.WARNING;
logMessage = `SLOW OPERATION. Duration > ${
this.loggingOptions.logWarningIfTryOverThreshold
} ms. `;
}
}
if (
(response.status >= 400 &&
response.status <= 499 &&
(response.status !== HTTPURLConnection.HTTP_NOT_FOUND &&
response.status !== HTTPURLConnection.HTTP_CONFLICT &&
response.status !== HTTPURLConnection.HTTP_PRECON_FAILED &&
response.status !== HTTPURLConnection.HTTP_RANGE_NOT_SATISFIABLE)) ||
(response.status >= 500 && response.status <= 509)
) {
const requestEndTime = new Date();
const requestCompletionTime = requestEndTime.getTime() - this.requestStartTime.getTime();
const operationDuration = requestEndTime.getTime() - this.operationStartTime.getTime();
let currentLevel: HttpPipelineLogLevel = HttpPipelineLogLevel.INFO;
let logMessage: string = "";
if (this.shouldLog(HttpPipelineLogLevel.INFO)) {
// Assume success and default to informational logging.
logMessage = "Successfully Received Response. ";
}
// If the response took too long, we'll upgrade to warning.
if (requestCompletionTime >= this.loggingOptions.logWarningIfTryOverThreshold) {
// Log a warning if the try duration exceeded the specified threshold.
if (this.shouldLog(HttpPipelineLogLevel.WARNING)) {
currentLevel = HttpPipelineLogLevel.WARNING;
logMessage = `SLOW OPERATION. Duration > ${
this.loggingOptions.logWarningIfTryOverThreshold
} ms. `;
}
}
if (
(response.status >= 400 &&
response.status <= 499 &&
(response.status !== HTTPURLConnection.HTTP_NOT_FOUND &&
response.status !== HTTPURLConnection.HTTP_CONFLICT &&
response.status !== HTTPURLConnection.HTTP_PRECON_FAILED &&
response.status !== HTTPURLConnection.HTTP_RANGE_NOT_SATISFIABLE)) ||
(response.status >= 500 && response.status <= 509)
) {
const errorString = `REQUEST ERROR: HTTP request failed with status code: ${