Skip to content

Commit

Permalink
feat: add ability to filter flutter output in dev log (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbadstuebner authored Aug 14, 2024
1 parent 5aa227f commit 654c477
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ require("flutter-tools").setup {
},
dev_log = {
enabled = true,
filter = nil, -- optional callback to filter the log
-- takes a log_line as string argument; returns a boolean or nil;
-- the log_line is only added to the output if the function returns true
notify_errors = false, -- if there is an error whilst running then notify the user
open_cmd = "tabedit", -- command to use to open the log buffer
},
Expand Down
1 change: 1 addition & 0 deletions lua/flutter-tools/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ local config = {
__index = function(_, k) return k == "open_cmd" and get_split_cmd(0.3, 40) or nil end,
}),
dev_log = setmetatable({
filter = nil,
enabled = true,
notify_errors = false,
}, {
Expand Down
1 change: 1 addition & 0 deletions lua/flutter-tools/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ end
function M.log(data, opts)
if opts.enabled then
if not exists() then create(opts) end
if opts.filter and not opts.filter(data) then return end
append(M.buf, { data })
autoscroll(M.buf, M.win)
end
Expand Down

0 comments on commit 654c477

Please sign in to comment.