Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Trigger Tag #539

Closed
sasq64 opened this issue Sep 11, 2018 · 2 comments
Closed

Feature Request: Trigger Tag #539

sasq64 opened this issue Sep 11, 2018 · 2 comments
Labels
enhancement Feature Request

Comments

@sasq64
Copy link

sasq64 commented Sep 11, 2018

For Android logcat, and other logging that shows output from multiple applications/sources, it is very useful to set up a rule saying:

  • If I see a line containing This particular text/tag, remember this Other field, and only show lines containing that field.

So in Androids case, I can say "When you see the text "MyApp Starting", save the ProcessID from that line, and filter out any lines from other processes.

Maybe it's already possible with some scripting ?

@tstack
Copy link
Owner

tstack commented Sep 11, 2018

That's an interesting idea. I don't think it's fully possible at the moment since lnav doesn't have a way to do something when new lines are loaded and filtering is still pretty limited. What you might be able to get working right now is a script like the following:

#
# @synopsis: myapp_filter
# @description: Create a :filter-in with all ProcessIDs for newly started instances of MyApp
#

# Find all instances of the log message "MyApp Starting" and combine the ProcessIDs
# into a regex for :filter-in stored in the 'filt' variable
;SELECT group_concat(ProcessID, '|') AS filt FROM mylog WHERE log_body LIKE '%MyApp Starting%'
# Execute the :filter-in, substituting the 'filt' variable from the SELECT
:eval :filter-in $filt

You can put that in a script (e.g. myapp_filter.lnav) and run it with '|/path/to/myapp_filter.lnav' in lnav. If you put it in a format directory (e.g. ~/.lnav/formats/installed), you can run it with '|myapp_filter' and lnav will tab-complete it as well.

You can clear the filter with CTRL-R.

@tstack tstack added the enhancement Feature Request label Sep 22, 2020
@tstack tstack closed this as completed in f9f797f Jun 29, 2022
@tstack
Copy link
Owner

tstack commented Jun 29, 2022

Well... four years later, I actually did something about this request. I don't know if you're even still interested in this, but if you are, I'd like your thoughts.

The approach is that you can now create "watch expressions" that will trigger an event to be sent. Here's the initial docs for the watches: https://docs.lnav.org/en/latest/config.html#watch-expressions-v0-10-2

Handling events is described here: https://docs.lnav.org/en/latest/events.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature Request
Projects
None yet
Development

No branches or pull requests

2 participants