• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tstack / lnav / 19771018346-2722

28 Nov 2025 06:02PM UTC coverage: 68.87% (+0.01%) from 68.859%
19771018346-2722

push

github

tstack
[formats] patch elb_log with some extra stuff

Related to #349

4 of 4 new or added lines in 1 file covered. (100.0%)

12 existing lines in 2 files now uncovered.

51238 of 74398 relevant lines covered (68.87%)

436147.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

45.32
/src/files_sub_source.cc
1
/**
2
 * Copyright (c) 2020, Timothy Stack
3
 *
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are met:
8
 *
9
 * * Redistributions of source code must retain the above copyright notice, this
10
 * list of conditions and the following disclaimer.
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 * this list of conditions and the following disclaimer in the documentation
13
 * and/or other materials provided with the distribution.
14
 * * Neither the name of Timothy Stack nor the names of its contributors
15
 * may be used to endorse or promote products derived from this software
16
 * without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
19
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29

30
#include <vector>
31

32
#include "files_sub_source.hh"
33

34
#include "base/ansi_scrubber.hh"
35
#include "base/attr_line.builder.hh"
36
#include "base/fs_util.hh"
37
#include "base/humanize.hh"
38
#include "base/humanize.network.hh"
39
#include "base/humanize.time.hh"
40
#include "base/itertools.enumerate.hh"
41
#include "base/itertools.hh"
42
#include "base/opt_util.hh"
43
#include "base/string_util.hh"
44
#include "config.h"
45
#include "lnav.hh"
46
#include "mapbox/variant.hpp"
47
#include "md4cpp.hh"
48
#include "sql_util.hh"
49

50
using namespace md4cpp::literals;
51
using namespace lnav::roles::literals;
52

53
namespace files_model {
54
files_list_selection
55
from_selection(std::optional<vis_line_t> sel_vis)
21✔
56
{
57
    if (!sel_vis) {
21✔
58
        return no_selection{};
13✔
59
    }
60

61
    auto& fc = lnav_data.ld_active_files;
8✔
62
    int sel = sel_vis.value();
8✔
63

64
    {
65
        safe::ReadAccess<safe_name_to_stubs> errs(*fc.fc_name_to_stubs);
8✔
66

67
        if (sel < (ssize_t) errs->size()) {
8✔
68
            auto iter = errs->begin();
×
69

70
            std::advance(iter, sel);
71
            return stub_selection::build(
×
72
                sel,
73
                std::make_pair(iter->second.fsi_display_name,
×
74
                               iter->second.fsi_description));
×
75
        }
76

77
        sel -= errs->size();
8✔
78
    }
8✔
79

80
    if (sel < (ssize_t) fc.fc_other_files.size()) {
8✔
81
        auto iter = fc.fc_other_files.begin();
×
82

83
        std::advance(iter, sel);
84
        return other_selection::build(sel, iter);
×
85
    }
86

87
    sel -= fc.fc_other_files.size();
8✔
88

89
    if (sel < (ssize_t) fc.fc_files.size()) {
8✔
90
        auto iter = fc.fc_files.begin();
8✔
91

92
        std::advance(iter, sel);
93
        return file_selection::build(sel, iter);
8✔
94
    }
95

96
    return no_selection{};
×
97
}
98
}  // namespace files_model
99

100
bool
UNCOV
101
files_sub_source::list_input_handle_key(listview_curses& lv, const ncinput& ch)
×
102
{
UNCOV
103
    switch (ch.eff_text[0]) {
×
104
        case NCKEY_ENTER:
×
105
        case '\r': {
106
            auto sel = files_model::from_selection(lv.get_selection());
×
107

108
            sel.match(
×
109
                [](files_model::no_selection) {},
×
110
                [](files_model::stub_selection) {},
×
111
                [](files_model::other_selection) {},
×
112
                [&](files_model::file_selection& fs) {
×
113
                    auto& lss = lnav_data.ld_log_source;
×
114
                    auto lf = *fs.sb_iter;
×
115

116
                    lf->set_indexing(true);
×
117
                    lss.find_data(lf) | [](auto ld) {
×
118
                        ld->set_visibility(true);
×
119
                        lnav_data.ld_log_source.text_filters_changed();
×
120
                    };
121

122
                    if (lf->get_format() != nullptr) {
×
123
                        auto& log_view = lnav_data.ld_views[LNV_LOG];
×
124
                        lss.row_for_time(lf->front().get_timeval()) |
×
125
                            [](auto row) {
×
126
                                lnav_data.ld_views[LNV_LOG].set_selection(row);
×
127
                            };
128
                        ensure_view(&log_view);
×
129
                    } else {
130
                        auto& tv = lnav_data.ld_views[LNV_TEXT];
×
131
                        auto& tss = lnav_data.ld_text_source;
×
132

133
                        tss.to_front(lf);
×
134
                        tv.reload_data();
×
135
                        ensure_view(&tv);
×
136
                    }
137

138
                    lv.reload_data();
×
139
                    set_view_mode(ln_mode_t::PAGING);
×
140
                });
×
141

142
            return true;
×
143
        }
144

145
        case ' ': {
×
146
            auto sel = files_model::from_selection(lv.get_selection());
×
147

148
            sel.match([](files_model::no_selection) {},
×
149
                      [](files_model::stub_selection) {},
×
150
                      [](files_model::other_selection) {},
×
151
                      [&](files_model::file_selection& fs) {
×
152
                          auto& lss = lnav_data.ld_log_source;
×
153
                          auto lf = *fs.sb_iter;
×
154

155
                          log_debug("toggling visibility of file: %s",
×
156
                                    lf->get_filename().c_str());
157
                          lss.find_data(lf) | [](auto ld) {
×
158
                              ld->get_file_ptr()->set_indexing(!ld->ld_visible);
×
159
                              ld->set_visibility(!ld->ld_visible);
×
160
                          };
161

162
                          auto top_view = *lnav_data.ld_view_stack.top();
×
163
                          auto tss = top_view->get_sub_source();
×
164

165
                          if (tss != nullptr) {
×
166
                              if (tss != &lss) {
×
167
                                  lss.text_filters_changed();
×
168
                                  lnav_data.ld_views[LNV_LOG].reload_data();
×
169
                              }
170
                              tss->text_filters_changed();
×
171
                              top_view->reload_data();
×
172
                          }
173

174
                          lv.reload_data();
×
175
                      });
×
176
            return true;
×
177
        }
178
        case '/': {
×
179
            execute_command(lnav_data.ld_exec_context, "prompt search-files");
×
180
            return true;
×
181
        }
182
        case 'X': {
×
183
            auto sel = files_model::from_selection(lv.get_selection());
×
184

185
            sel.match(
×
186
                [](files_model::no_selection) {},
×
187
                [&](files_model::stub_selection& es) {
×
188
                    auto& fc = lnav_data.ld_active_files;
×
189

190
                    fc.fc_file_names.erase(es.sb_iter.first);
×
191

192
                    auto name_iter = fc.fc_file_names.begin();
×
193
                    while (name_iter != fc.fc_file_names.end()) {
×
194
                        if (name_iter->first == es.sb_iter.first) {
×
195
                            fc.fc_file_names.erase(name_iter);
×
196
                            name_iter = fc.fc_file_names.begin();
×
197
                            continue;
×
198
                        }
199

200
                        auto rp_opt = humanize::network::path::from_str(
201
                            name_iter->first);
×
202

203
                        if (rp_opt) {
×
204
                            auto rp = *rp_opt;
×
205

206
                            if (fmt::to_string(rp.home()) == es.sb_iter.first) {
×
207
                                fc.fc_other_files.erase(name_iter->first);
×
208
                                fc.fc_file_names.erase(name_iter);
×
209
                                name_iter = fc.fc_file_names.begin();
×
210
                                continue;
×
211
                            }
212
                        }
213
                        ++name_iter;
×
214
                    }
215

216
                    fc.fc_name_to_stubs->writeAccess()->erase(es.sb_iter.first);
×
217
                    fc.fc_invalidate_merge = true;
×
218
                    lv.reload_data();
×
219
                },
×
220
                [](files_model::other_selection) {},
×
221
                [](files_model::file_selection) {});
×
222
            return true;
×
223
        }
224
    }
UNCOV
225
    return false;
×
226
}
227

228
void
229
files_sub_source::list_input_handle_scroll_out(listview_curses& lv)
×
230
{
231
    set_view_mode(ln_mode_t::PAGING);
×
232
    lnav_data.ld_filter_view.reload_data();
×
233
}
234

235
size_t
236
files_sub_source::text_line_count()
3,716✔
237
{
238
    const auto& fc = lnav_data.ld_active_files;
3,716✔
239
    auto retval = fc.fc_name_to_stubs->readAccess()->size()
3,716✔
240
        + fc.fc_other_files.size() + fc.fc_files.size();
3,716✔
241

242
    return retval;
3,716✔
243
}
244

245
size_t
246
files_sub_source::text_line_width(textview_curses& curses)
1✔
247
{
248
    return 512;
1✔
249
}
250

251
line_info
252
files_sub_source::text_value_for_line(textview_curses& tc,
1✔
253
                                      int line,
254
                                      std::string& value_out,
255
                                      text_sub_source::line_flags_t flags)
256
{
257
    bool selected = line == tc.get_selection();
1✔
258
    role_t cursor_role = lnav_data.ld_mode == ln_mode_t::FILES
2✔
259
        ? role_t::VCR_CURSOR_LINE
1✔
260
        : role_t::VCR_DISABLED_CURSOR_LINE;
261
    const auto& fc = lnav_data.ld_active_files;
1✔
262
    auto filename_width = std::min(fc.fc_largest_path_length, (size_t) 30);
1✔
263

264
    this->fss_curr_line.clear();
1✔
265
    auto& al = this->fss_curr_line;
1✔
266
    attr_line_builder alb(al);
1✔
267

268
    if (selected) {
1✔
269
        al.append(" ", VC_GRAPHIC.value(NCACS_RARROW));
1✔
270
    } else {
271
        al.append(" ");
×
272
    }
273
    {
274
        safe::ReadAccess<safe_name_to_stubs> errs(*fc.fc_name_to_stubs);
1✔
275

276
        if (line < (ssize_t) errs->size()) {
1✔
277
            auto iter = std::next(errs->begin(), line);
×
278
            auto path = std::filesystem::path(iter->second.fsi_display_name);
×
279
            auto fn = fmt::to_string(path.filename());
×
280

281
            truncate_to(fn, filename_width);
×
282
            al.append("   ");
×
283
            {
284
                auto ag = alb.with_attr(VC_ROLE.value(role_t::VCR_FILE));
×
285

286
                al.appendf(FMT_STRING("{:<{}}"), fn, filename_width);
×
287
            }
288
            al.append("   ");
×
289
            ui_icon_t icon = ui_icon_t::ok;
×
290
            switch (iter->second.fsi_description.um_level) {
×
291
                case lnav::console::user_message::level::raw:
×
292
                    break;
×
293
                case lnav::console::user_message::level::ok:
×
294
                    icon = ui_icon_t::ok;
×
295
                    break;
×
296
                case lnav::console::user_message::level::info:
×
297
                    icon = ui_icon_t::info;
×
298
                    break;
×
299
                case lnav::console::user_message::level::warning:
×
300
                    icon = ui_icon_t::warning;
×
301
                    break;
×
302
                case lnav::console::user_message::level::error:
×
303
                    icon = ui_icon_t::error;
×
304
                    break;
×
305
            }
306
            al.append(" ", VC_ICON.value(icon));
×
307
            if (selected) {
×
308
                al.with_attr_for_all(VC_ROLE.value(cursor_role));
×
309
            }
310

311
            value_out = al.get_string();
×
312
            return {};
×
313
        }
314

315
        line -= errs->size();
1✔
316
    }
1✔
317

318
    if (line < (ssize_t) fc.fc_other_files.size()) {
1✔
319
        auto iter = std::next(fc.fc_other_files.begin(), line);
×
320
        auto path = std::filesystem::path(iter->first);
×
321
        auto fn = fmt::to_string(path);
×
322

323
        truncate_to(fn, filename_width);
×
324
        al.append("   ");
×
325
        {
326
            auto ag = alb.with_attr(VC_ROLE.value(role_t::VCR_FILE));
×
327

328
            al.appendf(FMT_STRING("{:<{}}"), fn, filename_width);
×
329
        }
330
        al.append("   ")
×
331
            .appendf(FMT_STRING("{:14}"), iter->second.ofd_format)
×
332
            .append("  ")
×
333
            .append(iter->second.ofd_description);
×
334
        if (selected) {
×
335
            al.with_attr_for_all(VC_ROLE.value(cursor_role));
×
336
        }
337
        if (line == (ssize_t) fc.fc_other_files.size() - 1) {
×
338
            al.with_attr_for_all(VC_STYLE.value(text_attrs::with_underline()));
×
339
        }
340

341
        value_out = al.get_string();
×
342
        return {};
×
343
    }
344

345
    line -= fc.fc_other_files.size();
1✔
346

347
    const auto& lf = fc.fc_files[line];
1✔
348
    auto ld_opt = lnav_data.ld_log_source.find_data(lf);
1✔
349
    auto fn = fmt::to_string(std::filesystem::path(lf->get_unique_path()));
1✔
350

351
    truncate_to(fn, filename_width);
1✔
352
    al.append(" ");
1✔
353
    if (ld_opt) {
1✔
354
        if (ld_opt.value()->ld_visible) {
1✔
355
            al.append("\u25c6"_ok);
1✔
356
        } else {
357
            al.append("\u25c7"_comment);
×
358
        }
359
    } else {
360
        al.append("\u25c6"_comment);
×
361
    }
362
    al.append(" ");
1✔
363
    al.appendf(FMT_STRING("{:<{}}"), fn, filename_width);
4✔
364
    al.append("  ");
1✔
365
    {
366
        auto ag = alb.with_attr(VC_ROLE.value(role_t::VCR_NUMBER));
1✔
367

368
        al.appendf(FMT_STRING("{:>8}"),
4✔
369
                   humanize::file_size(lf->get_index_size(),
2✔
370
                                       humanize::alignment::columnar));
371
    }
1✔
372
    al.append(" ");
1✔
373
    auto indexed_size = lf->get_index_size();
1✔
374
    auto total_size = lf->get_content_size();
1✔
375
    if (!lf->get_decompress_error().empty()) {
1✔
376
        al.append(" ", VC_ICON.value(ui_icon_t::error));
×
377
    } else if (!lf->get_notes().empty()) {
1✔
378
        al.append(" ", VC_ICON.value(ui_icon_t::warning));
×
379
    } else if (indexed_size < total_size) {
1✔
380
        al.append(humanize::sparkline(indexed_size, total_size));
×
381
    } else {
382
        al.append(" ", VC_ICON.value(ui_icon_t::ok));
1✔
383
    }
384
    if (selected) {
1✔
385
        al.with_attr_for_all(VC_ROLE.value(cursor_role));
1✔
386
    }
387

388
    value_out = al.get_string();
1✔
389
    this->fss_last_line_len = value_out.length();
1✔
390

391
    return {};
1✔
392
}
1✔
393

394
void
395
files_sub_source::text_attrs_for_line(textview_curses& tc,
1✔
396
                                      int line,
397
                                      string_attrs_t& value_out)
398
{
399
    value_out = this->fss_curr_line.get_attrs();
1✔
400
}
1✔
401

402
size_t
403
files_sub_source::text_size_for_line(textview_curses& tc,
×
404
                                     int line,
405
                                     text_sub_source::line_flags_t raw)
406
{
407
    return 0;
×
408
}
409

410
static auto
411
spinner_index()
×
412
{
413
    auto now = ui_clock::now();
×
414

415
    return std::chrono::duration_cast<std::chrono::milliseconds>(
×
416
               now.time_since_epoch())
×
417
               .count()
×
418
        / 100;
×
419
}
420

421
bool
422
files_overlay_source::list_static_overlay(const listview_curses& lv,
15✔
423
                                          media_t media,
424
                                          int y,
425
                                          int bottom,
426
                                          attr_line_t& value_out)
427
{
428
    if (y != 0) {
15✔
429
        return false;
12✔
430
    }
431
    static const char PROG[] = "-\\|/";
432
    constexpr size_t PROG_SIZE = sizeof(PROG) - 1;
3✔
433

434
    auto& fc = lnav_data.ld_active_files;
3✔
435
    auto fc_prog = fc.fc_progress;
3✔
436
    safe::WriteAccess<safe_scan_progress> sp(*fc_prog);
3✔
437

438
    if (!sp->sp_extractions.empty()) {
3✔
439
        const auto& prog = sp->sp_extractions.front();
×
440

441
        value_out.with_ansi_string(fmt::format(
×
442
            "{} Extracting " ANSI_COLOR(COLOR_CYAN) "{}" ANSI_NORM
443
                                                    "... {:>8}/{}",
444
            humanize::sparkline(prog.ep_out_size, prog.ep_total_size),
×
445
            prog.ep_path.filename().string(),
×
446
            humanize::file_size(prog.ep_out_size, humanize::alignment::none),
×
447
            humanize::file_size(prog.ep_total_size,
×
448
                                humanize::alignment::none)));
449
        return true;
×
450
    }
451
    if (!sp->sp_tailers.empty()) {
3✔
452
        auto first_iter = sp->sp_tailers.begin();
×
453

454
        value_out.with_ansi_string(fmt::format(
×
455
            "{} Connecting to " ANSI_COLOR(COLOR_CYAN) "{}" ANSI_NORM ": {}",
456
            PROG[spinner_index() % PROG_SIZE],
×
457
            first_iter->first,
×
458
            first_iter->second.tp_message));
×
459
        return true;
×
460
    }
461

462
    return false;
3✔
463
}
3✔
464

465
bool
466
files_sub_source::text_handle_mouse(
×
467
    textview_curses& tc,
468
    const listview_curses::display_line_content_t&,
469
    mouse_event& me)
470
{
471
    auto nci = ncinput{};
×
472
    if (me.is_click_in(mouse_button_t::BUTTON_LEFT, 1, 3)) {
×
473
        nci.id = ' ';
×
474
        nci.eff_text[0] = ' ';
×
475
        this->list_input_handle_key(tc, nci);
×
476
    }
477
    if (me.is_double_click_in(mouse_button_t::BUTTON_LEFT, line_range{4, -1})) {
×
478
        nci.id = '\r';
×
479
        nci.eff_text[0] = '\r';
×
480
        this->list_input_handle_key(tc, nci);
×
481
    }
482

483
    return false;
×
484
}
485

486
void
487
files_sub_source::text_update_marks(vis_bookmarks& bm)
2,267✔
488
{
489
    auto& bm_errs = bm[&textview_curses::BM_ERRORS];
2,267✔
490
    auto& bm_warn = bm[&textview_curses::BM_WARNINGS];
2,267✔
491

492
    bm_errs.clear();
2,267✔
493
    bm_warn.clear();
2,267✔
494

495
    auto index = 0_vl;
2,267✔
496

497
    auto& fc = lnav_data.ld_active_files;
2,267✔
498
    {
499
        safe::ReadAccess<safe_name_to_stubs> stubs(*fc.fc_name_to_stubs);
2,267✔
500

501
        for (const auto& stub_pair : *stubs) {
2,267✔
502
            switch (stub_pair.second.fsi_description.um_level) {
×
503
                case lnav::console::user_message::level::warning:
×
504
                    bm_warn.insert_once(index);
×
505
                    break;
×
506
                case lnav::console::user_message::level::error:
×
507
                    bm_errs.insert_once(index);
×
508
                    break;
×
509
                default:
×
510
                    break;
×
511
            }
512
            index += 1_vl;
×
513
        }
514
    }
2,267✔
515

516
    index += vis_line_t(fc.fc_other_files.size());
2,267✔
517

518
    for (const auto& lf : fc.fc_files) {
3,172✔
519
        if (!lf->get_decompress_error().empty()) {
905✔
520
            bm_errs.insert_once(index);
×
521
        } else if (!lf->get_notes().empty()) {
905✔
522
            bm_warn.insert_once(index);
1✔
523
        }
524
        index += 1_vl;
905✔
525
    }
526
}
2,267✔
527

528
void
529
files_sub_source::text_selection_changed(textview_curses& tc)
21✔
530
{
531
    auto sel = files_model::from_selection(tc.get_selection());
21✔
532
    std::vector<attr_line_t> details;
21✔
533

534
    this->fss_details_mtime = std::chrono::microseconds::zero();
21✔
535
    sel.match(
21✔
536
        [](files_model::no_selection) {},
×
537

538
        [&details](const files_model::stub_selection& es) {
×
539
            es.sb_iter.second.to_attr_line().split_lines(details);
×
540
        },
×
541
        [&details](const files_model::other_selection& os) {
×
542
            auto path = std::filesystem::path(os.sb_iter->first);
×
543

544
            details.emplace_back(
×
545
                attr_line_t().appendf(FMT_STRING("Full path: {}"), path));
×
546
            details.emplace_back(attr_line_t("  ").append("Match Details"_h3));
×
547
            for (const auto& msg : os.sb_iter->second.ofd_details) {
×
548
                auto msg_al = msg.to_attr_line();
×
549

550
                for (auto& msg_line : msg_al.rtrim().split_lines()) {
×
551
                    msg_line.insert(0, 4, ' ');
×
552
                    details.emplace_back(msg_line);
×
553
                }
554
            }
555
        },
×
556
        [&details, this](const files_model::file_selection& fs) {
21✔
557
            static constexpr auto NAME_WIDTH = 17;
558

559
            auto lf = *fs.sb_iter;
8✔
560
            this->fss_details_mtime = lf->get_modified_time();
8✔
561
            auto path = lf->get_filename();
8✔
562
            auto actual_path = lf->get_actual_path();
8✔
563
            auto format = lf->get_format();
8✔
564
            const auto& open_opts = lf->get_open_options();
8✔
565

566
            details.emplace_back(attr_line_t()
16✔
567
                                     .appendf(FMT_STRING("{}"), path.filename())
40✔
568
                                     .with_attr_for_all(VC_STYLE.value(
16✔
569
                                         text_attrs::with_bold())));
16✔
570
            details.emplace_back(
8✔
571
                attr_line_t("  ")
8✔
572
                    .append(":open_file_folder:"_emoji)
16✔
573
                    .appendf(FMT_STRING(" {}"), path.parent_path()));
32✔
574

575
            const auto& decompress_err = lf->get_decompress_error();
8✔
576
            if (!decompress_err.empty()) {
8✔
577
                details.emplace_back(
×
578
                    attr_line_t("  ")
×
579
                        .append("Error"_h2)
×
580
                        .append(": ")
×
581
                        .append(lnav::roles::error(decompress_err)));
×
582
            }
583

584
            const auto notes = lf->get_notes();
8✔
585
            if (!notes.empty()) {
8✔
586
                details.emplace_back(
×
587
                    attr_line_t("  ").append("Notes"_h2).append(":"));
×
588
                for (const auto& note_um : notes.values()) {
×
589
                    for (const auto& note_line :
×
590
                         note_um.to_attr_line().split_lines())
×
591
                    {
592
                        details.emplace_back(
×
593
                            attr_line_t("    ").append(note_line));
×
594
                    }
595
                }
596
            }
597
            details.emplace_back(attr_line_t("  ").append("General"_h2));
8✔
598
            if (actual_path) {
8✔
599
                if (path != actual_path.value()) {
8✔
600
                    auto line = attr_line_t()
×
601
                                    .append("Actual Path"_h3)
×
602
                                    .right_justify(NAME_WIDTH)
×
603
                                    .append(": ")
×
604
                                    .append(lnav::roles::file(
×
605
                                        fmt::to_string(actual_path.value())))
×
606
                                    .move();
×
607
                    details.emplace_back(line);
×
608
                }
609
            } else {
610
                details.emplace_back(attr_line_t().append("  Piped"));
×
611
            }
612
            details.emplace_back(
8✔
613
                attr_line_t()
8✔
614
                    .append("MIME Type"_h3)
8✔
615
                    .right_justify(NAME_WIDTH)
8✔
616
                    .append(": ")
8✔
617
                    .append(fmt::to_string(lf->get_text_format())));
16✔
618
            auto ltime = std::chrono::seconds{
619
                convert_log_time_to_local(lf->get_stat().st_mtime)};
8✔
620
            auto ltime_str = lnav::to_rfc3339_string(ltime, 'T');
8✔
621
            details.emplace_back(attr_line_t()
16✔
622
                                     .append("Last Modified"_h3)
8✔
623
                                     .right_justify(NAME_WIDTH)
8✔
624
                                     .append(": ")
8✔
625
                                     .append(ltime_str));
626
            details.emplace_back(
8✔
627
                attr_line_t()
8✔
628
                    .append("Size"_h3)
8✔
629
                    .right_justify(NAME_WIDTH)
8✔
630
                    .append(": ")
8✔
631
                    .append(humanize::file_size(lf->get_index_size(),
16✔
632
                                                humanize::alignment::none)));
633
            if (lf->is_compressed()) {
8✔
634
                details.emplace_back(attr_line_t()
×
635
                                         .append("Compressed Size"_h3)
×
636
                                         .right_justify(NAME_WIDTH)
×
637
                                         .append(": ")
×
638
                                         .append(humanize::file_size(
×
639
                                             lf->get_stat().st_size,
×
640
                                             humanize::alignment::none)));
641
            }
642

643
            details.emplace_back(attr_line_t()
16✔
644
                                     .append("Lines"_h3)
8✔
645
                                     .right_justify(NAME_WIDTH)
8✔
646
                                     .append(": ")
8✔
647
                                     .append(lnav::roles::number(fmt::format(
16✔
648
                                         FMT_STRING("{:L}"), lf->size()))));
32✔
649
            if (format != nullptr && lf->size() > 0) {
8✔
650
                auto tr = lf->get_content_time_range();
7✔
651
                details.emplace_back(attr_line_t()
14✔
652
                                         .append("Time Range"_h3)
7✔
653
                                         .right_justify(NAME_WIDTH)
7✔
654
                                         .append(": ")
7✔
655
                                         .append(lnav::to_rfc3339_string(
14✔
656
                                             to_timeval(tr.tr_begin), 'T'))
657
                                         .append(" - ")
7✔
658
                                         .append(lnav::to_rfc3339_string(
14✔
659
                                             to_timeval(tr.tr_end), 'T')));
660
                if (open_opts.loo_time_range.has_lower_bound()) {
7✔
661
                    details.emplace_back(
×
662
                        attr_line_t()
×
663
                            .append("Cutoff From"_h3)
×
664
                            .right_justify(NAME_WIDTH)
×
665
                            .append(": ")
×
666
                            .append(lnav::to_rfc3339_string(
×
667
                                to_timeval(open_opts.loo_time_range.tr_begin),
668
                                'T')));
669
                }
670
                if (open_opts.loo_time_range.has_upper_bound()) {
7✔
671
                    details.emplace_back(
×
672
                        attr_line_t()
×
673
                            .append("Cutoff To"_h3)
×
674
                            .right_justify(NAME_WIDTH)
×
675
                            .append(": ")
×
676
                            .append(lnav::to_rfc3339_string(
×
677
                                to_timeval(open_opts.loo_time_range.tr_end),
678
                                'T')));
679
                }
680
                details.emplace_back(
7✔
681
                    attr_line_t()
14✔
682
                        .append("Duration"_h3)
7✔
683
                        .right_justify(NAME_WIDTH)
7✔
684
                        .append(": ")
7✔
685
                        .append(humanize::time::duration::from_tv(
7✔
686
                                    lf->back().get_timeval()
7✔
687
                                    - lf->front().get_timeval())
14✔
688
                                    .to_string()));
14✔
689
            }
690

691
            auto file_options_opt = lf->get_file_options();
8✔
692
            if (file_options_opt) {
8✔
693
                auto& [path, file_options] = file_options_opt.value();
×
694

695
                details.emplace_back(attr_line_t()
×
696
                                         .append("Options Path"_h3)
×
697
                                         .right_justify(NAME_WIDTH)
×
698
                                         .append(": ")
×
699
                                         .append(lnav::roles::file(path)));
×
700
                if (file_options.fo_default_zone.pp_value != nullptr) {
×
701
                    details.emplace_back(attr_line_t()
×
702
                                             .append("Timezone"_h3)
×
703
                                             .right_justify(NAME_WIDTH)
×
704
                                             .append(": ")
×
705
                                             .append(lnav::roles::symbol(
×
706
                                                 file_options.fo_default_zone
707
                                                     .pp_value->name())));
×
708
                }
709
            }
710

711
            {
712
                details.emplace_back(
8✔
713
                    attr_line_t()
8✔
714
                        .append("Provenance"_h3)
8✔
715
                        .right_justify(NAME_WIDTH)
8✔
716
                        .append(": ")
8✔
717
                        .append(fmt::to_string(open_opts.loo_source)));
16✔
718
                details.emplace_back(
8✔
719
                    attr_line_t()
8✔
720
                        .append("Flags"_h3)
8✔
721
                        .right_justify(NAME_WIDTH)
8✔
722
                        .append(": ")
8✔
723
                        .append(lnav::roles::for_flag(
16✔
724
                            "\u2022", open_opts.loo_include_in_session))
8✔
725
                        .append("include-in-session")
8✔
726
                        .append(", ")
8✔
727
                        .append(lnav::roles::for_flag(
16✔
728
                            "\u2022", open_opts.loo_detect_format))
8✔
729
                        .append("detect-format"));
730
                if (open_opts.loo_init_location.valid()) {
8✔
731
                    auto loc = open_opts.loo_init_location.match(
732
                        [](default_for_text_format) {
8✔
733
                            return std::string("default");
16✔
734
                        },
735
                        [](file_location_tail) { return std::string("tail"); },
×
736
                        [](int vl) {
×
737
                            return fmt::format(FMT_STRING("L{:L}"), vl);
×
738
                        },
739
                        [](std::string section) { return section; });
8✔
740
                    details.emplace_back(attr_line_t()
16✔
741
                                             .append("Initial Location"_h3)
8✔
742
                                             .right_justify(NAME_WIDTH)
8✔
743
                                             .append(": ")
8✔
744
                                             .append(loc));
745
                }
8✔
746
            }
747

748
            {
749
                auto line = attr_line_t("  ")
16✔
750
                                .append("Log Format"_h2)
8✔
751
                                .append(": ")
8✔
752
                                .move();
8✔
753

754
                if (format != nullptr) {
8✔
755
                    line.append(lnav::roles::identifier(
7✔
756
                        format->get_name().to_string()));
14✔
757
                } else {
758
                    line.append("(none)"_comment);
1✔
759
                }
760
                details.emplace_back(line);
8✔
761
            }
8✔
762

763
            if (lf->get_format_ptr() != nullptr) {
8✔
764
                const auto um = lnav::console::user_message::info(
765
                    attr_line_t("The file contents matched this log format and "
14✔
766
                                "will be shown in the LOG view"));
7✔
767
                um.to_attr_line().rtrim().split_lines()
14✔
768
                    | lnav::itertools::for_each([&details](const auto& al) {
14✔
769
                          details.emplace_back(attr_line_t("    ").append(al));
7✔
770
                      });
7✔
771
            } else {
7✔
772
                auto cmd
773
                    = attr_line_t("lnav -m format ")
1✔
774
                          .append("format-name",
1✔
775
                                  VC_STYLE.value(text_attrs::with_underline()))
2✔
776
                          .append(" test ")
1✔
777
                          .append(lf->get_filename())
1✔
778
                          .with_attr_for_all(
1✔
779
                              VC_ROLE.value(role_t::VCR_QUOTED_CODE));
2✔
780
                const auto um
781
                    = lnav::console::user_message::info(
2✔
782

783
                          "The file contents did not match any log "
784
                          "formats and can be accessed in the TEXT view")
785
                          .with_help(attr_line_t("If you expected this file to "
2✔
786
                                                 "match a particular "
787
                                                 "format, you can run the "
788
                                                 "following to get more "
789
                                                 "details:\n  ")
790
                                         .append(cmd));
1✔
791
                um.to_attr_line().rtrim().split_lines()
2✔
792
                    | lnav::itertools::for_each([&details](const auto& al) {
2✔
793
                          details.emplace_back(attr_line_t("    ").append(al));
3✔
794
                      });
3✔
795
            }
1✔
796

797
            const auto& match_msgs = lf->get_format_match_messages();
8✔
798
            details.emplace_back(
8✔
799
                attr_line_t("    ").append("Match Details"_h3));
16✔
800
            for (const auto& msg : match_msgs) {
95✔
801
                auto msg_al = msg.to_attr_line();
87✔
802

803
                for (auto& msg_line : msg_al.rtrim().split_lines()) {
400✔
804
                    msg_line.insert(0, 6, ' ');
313✔
805
                    details.emplace_back(msg_line);
313✔
806
                }
87✔
807
            }
87✔
808

809
            const auto& ili = lf->get_invalid_line_info();
8✔
810
            if (ili.ili_total > 0) {
8✔
811
                auto dotdot = ili.ili_total
×
812
                    > logfile::invalid_line_info::MAX_INVALID_LINES;
813
                auto um = lnav::console::user_message::error(
×
814
                              attr_line_t()
×
815
                                  .append(lnav::roles::number(
×
816
                                      fmt::to_string(ili.ili_total)))
×
817
                                  .append(" line(s) are not handled by the "
×
818
                                          "format and considered invalid"))
819
                              .with_note(attr_line_t("Lines: ")
×
820
                                             .join(ili.ili_lines, ", ")
×
821
                                             .append(dotdot ? ", ..." : ""))
×
822
                              .with_help(
×
823
                                  "The format may be need to be adjusted to "
824
                                  "capture these lines");
×
825

826
                details.emplace_back(attr_line_t());
×
827
                um.to_attr_line().rtrim().split_lines()
×
828
                    | lnav::itertools::for_each([&details](const auto& al) {
×
829
                          details.emplace_back(attr_line_t("    ").append(al));
×
830
                      });
×
831
            }
832

833
            {
834
                const auto& meta = lf->get_embedded_metadata();
8✔
835

836
                if (!meta.empty()) {
8✔
837
                    details.emplace_back(
×
838
                        attr_line_t("  ").append("Embedded Metadata:"_h2));
×
839
                    for (const auto& [index, meta_pair] :
×
840
                         lnav::itertools::enumerate(meta))
×
841
                    {
842
                        details.emplace_back(
×
843
                            attr_line_t("  ")
×
844
                                .appendf(FMT_STRING("[{}]"), index)
×
845
                                .append(" ")
×
846
                                .append(lnav::roles::h3(meta_pair.first)));
×
847
                        details.emplace_back(
×
848
                            attr_line_t("      MIME Type: ")
×
849
                                .append(lnav::roles::symbol(fmt::to_string(
×
850
                                    meta_pair.second.m_format))));
×
851
                        line_range lr{6, -1};
×
852
                        details.emplace_back(attr_line_t().with_attr(
×
853
                            string_attr{lr, VC_GRAPHIC.value(NCACS_HLINE)}));
×
854
                        const auto val_sf = string_fragment::from_str(
×
855
                            meta_pair.second.m_value);
×
856
                        for (const auto val_line : val_sf.split_lines()) {
×
857
                            details.emplace_back(
×
858
                                attr_line_t("      ").append(val_line));
×
859
                        }
860
                    }
861
                }
862
            }
863
        });
8✔
864

865
    this->fss_details_source->replace_with(details);
21✔
866
}
21✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc