ToposPlayground::Command::Logs
Inherits ToposPlayground::Command < Reference < Object
Constants
Class methods
Instance methods
Given a sorted array of logs, calculate the standard deviation of the gaps in time between each of the logs.
Execute the logic of the list command. Logs are sorted by the timestamp embedded
into the UUID in the filename. If the UUID doesn't encode a valid timestamp, then
the file modification time is used. If it does encode a valid timestamp, but the
timestamp is for a time later than now, the file modification time is used. Likewise,
if there is a gap between the timestamp of one log file and the next that is greater
than twice the standard deviation of the gaps between all of the log file, the timestamp
will be taken from the file modification time.
This heuristic lets the log files generated by this version of the playground, which are part of the UUID in the filename, to take precedence when sorting the files, but it allows the playground binary to also function in a reasonable and predictable way with log files generated by the official Node.js version.
Using the sorting heuristic for #do_list to sort files, allow pruning of log files
by age, size, or range. The age is calculated in the same way as with the #do_list
method. Ranges are indexed with 1 being the most recent file.
Delete log files older than the specified number of days.
Delete log files within the specified range. Ranges are indexed with 1 being the most recent file. Alternatively, delete specific log files, by index, either alone, or in a comma separated list.
Delete log files smaller than the specified size. This is useful for getting rid of log files that are empty, or that contain only a few lines of output.
Using the sorting heuristic for #do_list to sort files, allow viewing of an individual
log file, selected by index, or by date/time -- the first file before or after a given
date/time.
Find the log file specified by the selector, which is a date/time, and display it. This will show the first log file with a timestamp later than the selector.
Find the log file specified by the selector, which is a date/time, and display it. This will show the first log file with a timestamp earlier than the selector.
Find the log file specified by the selector, which is an index into the sorted list of log files, most recent first, and display it. If the selector is emtpy, show the most recent log file.
If there are any log files with a filename that reflects a timestamp later than the current time, then it must be a randomly generated UUID from the official Node.js version of the topos-playground; pull the timestamp from the last modification time.
With a modest statistical probability of being wrong, this should be able to identify those logs which have accidentally created valid UUID timestamps that are too early in time to have been generated by this version of the playground. If the gap between them is greater than three times the standard deviation, it will use the file modification time instead of the timestamp.
Parse a size selector, which can be a number, or a number followed by a unit,
into a byte count. For example, 128b or 10k or 1mor4g`.
print the header for the sorted list of logs
There are two formats for the header, depending on whether the logs will be printed in single line format or multi-line format.
Print the sorted list of logs.
This is comprised of a header, and then a line for each log file. If the single-line format is too wide for the terminal, the multi-line format will be used. Regarding, though, line wrapping is still applied, so that everything stays relatively formatted, even on small terminal windows.