acquia / logstream-chrome

Allows you to see what logs are being generated in real time as you browse around a website that you maintain on Acquia Cloud
https://docs.acquia.com/cloud/configure/logging/stream
Other
7 stars 3 forks source link

Make filtering operate on logs only after they're recorded #1

Open IceCreamYou opened 8 years ago

IceCreamYou commented 8 years ago

Currently, there are three types of log filtering:

All three cause logs not matching their criteria to be dropped instead of written to the DOM. As a result, changing the criteria later will not change which logs appear in the stream.

Instead, the extension should make the filtering apply to logs after they're written to the DOM instead of when they're streamed. This will allow people to search streamed logs instead of only filtering them when they first arrive.

Then, the "Filter" label should be changed to "Search" since that is more descriptive of what it will do.

IceCreamYou commented 8 years ago

Note that this will cause an issue with keeping a limited number of log entries. The purging will either need to be improved such that a minimum number of visible logs are kept, or changed so that logs are kept for a certain amount of time (but a minimum number are kept), or both.

If logs are kept for a certain amount of time, that amount of time could be dynamically calculated based on the rate of receiving logs in order to keep the list from getting too big while not looking weird when logs roll in slowly. This can be done using an exponential moving average of the number of log entries received per second:

runningLogsPerSecond = 0.25 * logEntriesReceivedThisSecond + 0.75 * runningLogsPerSecond;
dropLogEntriesOlderThan = Math.min(1000 / runningLogsPerSecond, 10); // seconds old

Also, time-based purging should probably be triggered when the browser is idle and executed during a requestAnimationFrame callback, or at least not executed every time a log is recorded to avoid DOM thrashing.

I should ask / investigate how the Cloud UI removes old log entries to see if it makes sense to reuse that method or if I'm micro-optimizing.