MobDev.Server.LogFilter (mob_dev v0.3.37)

Copy Markdown View Source

Pure filter functions for the log stream. Extracted here so they can be unit-tested without mounting a LiveView.

Summary

Functions

Filters a list of log lines by device/category filter, then by text.

Returns true if the line passes both the device filter and the text filter.

Types

filter()

@type filter() :: :all | :app | String.t()

line()

@type line() :: map()

Functions

apply(lines, filter, text)

@spec apply([line()], filter(), String.t()) :: [line()]

Filters a list of log lines by device/category filter, then by text.

filter is :all, :app, or a device serial string. text is a comma-separated list of search terms (empty string = no filter). Lines newest-first; order is preserved.

by_device(lines, serial)

@spec by_device([line()], filter()) :: [line()]

by_device?(line, serial)

@spec by_device?(line(), filter()) :: boolean()

by_text(lines, text)

@spec by_text([line()], String.t()) :: [line()]

by_text?(line, text)

@spec by_text?(line(), String.t()) :: boolean()

matches?(line, filter, text)

@spec matches?(line(), filter(), String.t()) :: boolean()

Returns true if the line passes both the device filter and the text filter.