lnav icon indicating copy to clipboard operation
lnav copied to clipboard

[Feature request ] export marked section to file

Open cw1nte opened this issue 5 years ago • 8 comments

Useful to be able to name regions for an event (e.g. from this to that time around my event of interest). To make more of it I'd like to see a list of my regions (a sql query can probably do it, but just need to know where data is stored). I suppose also it would be useful to... :go_to my_region [head|tail?]

Maybe these features could parallel their methods with the filtering features as per tree head? [TAB for filters, R for regions?] or [TAB for options]-> R=regions, F=filters, M=marks & ...?
Move, space,D(elete) and Enter do the on/off/swap/delete/goto functions?

  • Regions might need start & end points? suspect they just start at present.
  • Show the line numbers, enter with cursor on the line number takes us there?
  • Filters I would still like to show the count of matches in such a display!

MOST useful, to export the named region to a file, full width text and maybe with/without colouring option? so something like.... :export-plain my_region /file/path/save1 :export_full my_region /file/path2/save2 I would suggest the padding to right and grouping bars at end are not that useful and padding to longest line seems extra work and storage... so not that?

Is there a way to clear the naming at the end of a region. So "my_event"=lines 200 to 1324, from 1325 on is not named yet?

cw1nte avatar Dec 17 '18 12:12 cw1nte

Having quit & restart nav on same data I am fairly sure my named region is no longer defined. I assumed it might save with the view data....

cw1nte avatar Dec 17 '18 13:12 cw1nte

I did not find it documented, but, GOOD NEWS, line marking offers quite a lot! Lowercase m to mark one end of a range and Shift-M uppercase for the other end seems to help do just what I want! Pretty sure single lines can be deselected with another m on a line currently selected line, and likewise other singles lines or ranges added. These lines can then be easily spotted, written out to file and moved to (next/previous, u/U, seems to move to next block or line at a time if contiguous group of marked lines, GREAT).

Now how about "name current set of marked lines as...." command? And that this lives/survives with the session data. Probably still desirable to have a [TAB] > M=marked lines >

current first=1234 6 gaps last=3456 (no save) myEvent1 first=5678 no gaps last =5697 (written to /path/myEvent) * unsaved changes myGroup2 first=12345 no gaps last =12567 (no save)

with ability to :

  • clear current marks
  • with the mark-set the cursor is on: make-current (loose existing), add to current, excl from current
  • delete mark-set (with option to delete saved file it it was saved),
  • save to file(again if previously done),
  • (rename?)
  • toggle reverse video mode (on current marks)

I imagine there is just one set of current/active marks, features to allow rapid and flexible manipulation of the current marked lines... This would be a superset of the naming feature perhaps, the title row name next to date/time could show the name of mark region (e.g. current (in case reverse off), myEvent1 etc.) [A gap is a group of one or more lines not marked.]

cw1nte avatar Dec 19 '18 09:12 cw1nte

Maybe timestamps are more useful than line numbers if user is filtering in/out but uses much more space. Would marks hidden by current filter-out be noted in mark-set summary? and some might be in while some others filtered out.... [45 hidden by filters] If a user range, when being defined by user, could include currently filtered out lines is this an option to ask about or ignore. I think ignore as they are marking their interest. It could lead to difficulty in maintaining at least the gaps summary data later if active filters change!

cw1nte avatar Dec 19 '18 09:12 cw1nte

IS there any way to clear all marks in file? They do survive quit & restore session. Now that I have many I want to make a new set and it is quite an extra job to clear the existing 350 clump by clump.

cw1nte avatar Dec 19 '18 12:12 cw1nte

Press 'Shift+C' to clear all marks (https://lnav.readthedocs.io/en/latest/hotkeys.html#bookmarks).

tstack avatar Dec 19 '18 15:12 tstack

So good, so good.... Thank you! sorry I missed it there, lots of useful tips so must keep that to hand until I know them all.

cw1nte avatar Dec 19 '18 15:12 cw1nte

Have you tried the :partition-name command? (see https://lnav.readthedocs.io/en/latest/commands.html#bookmarks)

I think that does roughly what you describe. Here's the flow:

  1. Make the start of the region you're interested in the top line in the log view.
  2. Set the name of the region with :partition-name myregion1
  3. Make the end of the region you're interested in the top line in the log view.
  4. Set the name of the next region with :partition-name myregion2

Once the region is defined, you can do a SELECT based on the log_part column with the name of the region.

;SELECT log_text FROM all_logs WHERE log_part = 'myregion1'

Then, you can use the :write-raw-to command in the SQL view to write the messages to a file.

:write-raw-to /tmp/myregion1.log

tstack avatar Dec 19 '18 15:12 tstack

Yes, sort of tried that. Was a bit put off to name regions I did not care for, but figured only way to get region_A might be to follow it with some other region. The SQL trick is quite useful. Overall I think I'd use the marking blocks of lines and direct write/append options more (have done so far) but the marking does not apply a displayable name, swings & roundabouts... I was trying to get it all in one bag, but only an idea. Useful to be able to select in & weed out while marking too, while it's fresh in mind etc ... Thanks.

cw1nte avatar Dec 19 '18 16:12 cw1nte