Skip to content

Commit 3595398

Browse files
feat: log_filter for flutter output
1 parent 5aa227f commit 3595398

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ require("flutter-tools").setup {
240240
},
241241
dev_log = {
242242
enabled = true,
243+
filter = nil, -- optional callback to filter the log
244+
-- takes a log_line as string argument; returns a boolean or nil;
245+
-- the log_line is only added to the output if the function returns true
243246
notify_errors = false, -- if there is an error whilst running then notify the user
244247
open_cmd = "tabedit", -- command to use to open the log buffer
245248
},

lua/flutter-tools/config.lua

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ local config = {
128128
__index = function(_, k) return k == "open_cmd" and get_split_cmd(0.3, 40) or nil end,
129129
}),
130130
dev_log = setmetatable({
131+
filter = nil,
131132
enabled = true,
132133
notify_errors = false,
133134
}, {

lua/flutter-tools/log.lua

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ end
8787
function M.log(data, opts)
8888
if opts.enabled then
8989
if not exists() then create(opts) end
90+
if opts.filter and not opts.filter(data) then return end
9091
append(M.buf, { data })
9192
autoscroll(M.buf, M.win)
9293
end

0 commit comments

Comments
 (0)