Log events with elapsed time, configurable delay, and abort
You are tasked with developing a part of an Event Logger system, specifically focusing on the feature that sends requests and logs events with a configurable delay. The goal is to simulate the behavior of sending requests to a server and logging the events, including the time elapsed since the initialization of the logger. The system should allow for a delay in logging to mimic network latency or processing time, and it should also provide functionality to abort a logging request. You can implement the delay with setTimeout().
The requirements for this part of the Event Logger system are as follows:
Example usage:
// Initialize the logger
_initializeStartTime();
// Set a simulated delay of 500ms for logging events
_setFetchResponseDelay(500);
// Send a logging request
const logRequest = sendRequest({ event: 'UserLogin', details: 'User logged in successfully' });
// Optionally, the logging request can be aborted
// logRequest.abort();
The expected output should include the logged events with their respective elapsed times and indicate whether they were aborted.