class

ToposPlayground::Command::Logs

Inherits ToposPlayground::Command < Reference < Object

Constants

UUID_REGEXP = /([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})/

Class methods

levenshtein_options
Source
list_options(parser, config)
Source
log_to_file?(config)
Source
options(parser, config)
Source
prune_options(parser, config)
Source
view_options(parser, config)
Source

Instance methods

calculate_gaps_and_standard_deviation(logs)

Given a sorted array of logs, calculate the standard deviation of the gaps in time between each of the logs.

Source
do_list

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.

Source
do_prune

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.

Source
do_prune_days(sorted_logs, selector)

Delete log files older than the specified number of days.

Source
do_prune_range(sorted_logs, selector)

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.

Source
do_prune_size(sorted_logs, selector)

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.

Source
do_view

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.

Source
do_view_after(sorted_logs, 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 later than the selector.

Source
do_view_before(sorted_logs, 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.

Source
do_view_index(sorted_logs, 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.

Source
generate_base_list

Perform the first pass at creating a list of log files.

Source
handle_erroneously_old_logs(logs) : Array(Tuple(String, String, Time))

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.

Source
handle_erroneously_young_logs(logs, gaps, standard_deviation)

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.

Source
multi_line_header(logs)

Build the multi-line header.

 #                                             Log File Path
                  File Date                File Size
Source
parse_to_size(selector)

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`.

Source
run

Act on the log subcommand (list, view, or prune).

Source
show_deletion_count(count)

Output the number of deleted files.

Source
show_log_file(log)

Display the given log file.

Source
single_line_header(logs)

Build the single-line header.

#                                             Log File Path                                                             File Date                File Size
Source