Skip to content

Commit c850b57

Browse files
committed
[docs] add notes on log2src integration
1 parent bd8a9ce commit c850b57

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

docs/notes/log2src.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
# log2src integration
3+
4+
The [Extracting Data](https://docs.lnav.org/en/latest/data.html)
5+
functionality in lnav parsed log message bodies based on various
6+
conventions, such as a key/value pair separated by an equal sign.
7+
That approach can work if the data is nicely structured, but is
8+
not totally reliable. As an alternative, if the logging source
9+
code is available, we can leverage log2src to find the
10+
corresponding log statement for a log message. We can then
11+
fairly accurately extract the values and pair them up with the
12+
appropriate variables. This functionality can be exposed to the
13+
user in two ways:
14+
15+
* Directly in lnav by replacing the "Discovered fields for ..."
16+
section in the message details overlay (shown by pressing `p`).
17+
In addition, we can now show the source code of the log
18+
statement.
19+
* Through a Debug Adapter that allows the user to treat the log
20+
as a trace of the execution of the program. For example, in
21+
VS Code, the user can set breakpoints on log statements and
22+
examine variable values at different points in time.
23+
24+
The following sections will go into details on demos for these
25+
two approaches.
26+
27+
## Standalone Demo
28+
29+
This demo covers modifying only lnav to show the results of
30+
log2src's magic. It's mostly retreading existing ground, so
31+
it should be more tractable than trying to get the debugger
32+
stuff working first.
33+
34+
Steps:
35+
1. Open log file generated by the program under development
36+
1. Add source directories to lnav (using a command?)
37+
1. Press `p` to reveal the message details overlay
38+
1. Note that lnav is showing the source code of the log statement
39+
for the focused log message and printed out the values of
40+
the variables.
41+
42+
Implementation tasks:
43+
44+
- [ ] Make sure log2src's API is usable
45+
- [ ] Rename lnav's prqlc-c crate since all Rust code will now be
46+
exposed through this crate
47+
- [ ] Add FFI interface for log2src's API to the crate
48+
- [ ] Add an lnav command to add source directories
49+
- [ ] Make the source directories part of the session
50+
- [ ] Check if a log message is recognized by log2src in the
51+
message details overlay and use those results if so.
52+
- [ ] Show the source code of the log message and surrounding bits
53+
- [ ] Modify the `all_logs` table to use log2src instead of the
54+
current extraction code.
55+
56+
57+
## Debugger Demo
58+
59+
This demo is probably the more useful one since it allows
60+
people to stay in their editor.
61+
62+
Steps:
63+
1. Open log file generated by the program under development
64+
1. Add source directories to lnav
65+
1. Set a breakpoint on a logging statement
66+
1. Attach the debugger to lnav
67+
1. Click "Run" to have lnav move the focused line to a breakpoint
68+
1. Show that the editor has moved to the source code
69+
containing the breakpoint and the variables passed to
70+
the log statement are shown.

0 commit comments

Comments
 (0)