Skip to content

Commit 92b7cc5

Browse files
committed
[timeline] try a different approach with header
1 parent 4888eaf commit 92b7cc5

18 files changed

+352
-366
lines changed

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ Interface changes:
132132
* The `}` hotkey and `:next-section` command will now
133133
move to the next log message if the focused line is
134134
in the middle of a multi-line message.
135+
* The TIMELINE view header has been redesigned to be
136+
one line that shows the time increments at the
137+
current scale. This approach should more clearly
138+
convey the spans of time shown in the main part of the
139+
view. The previous design tried to show the overall
140+
time and the current time frame. But, the multi-line
141+
header was hard to interpret and didn't make it clear
142+
how large the time increments were.
135143

136144
Bug Fixes:
137145
* If a file path contains a hash (`#`), check if the path

src/archive_manager.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ extract(const std::string& filename, const extract_cb& cb)
268268
if (fs::exists(done_path)) {
269269
size_t file_count = 0;
270270
if (fs::is_directory(tmp_path)) {
271-
for (const auto& entry : fs::directory_iterator(tmp_path)) {
271+
for (const auto& entry : fs::directory_iterator(tmp_path, ec)) {
272272
(void) entry;
273273
file_count += 1;
274274
}
@@ -415,9 +415,10 @@ cleanup_cache()
415415
auto cache_path = archive_cache_path();
416416
const auto& cfg = injector::get<const config&>();
417417
std::vector<fs::path> to_remove;
418+
std::error_code ec;
418419

419420
log_debug("cache-ttl %d", cfg.amc_cache_ttl.count());
420-
for (const auto& entry : fs::directory_iterator(cache_path)) {
421+
for (const auto& entry : fs::directory_iterator(cache_path, ec)) {
421422
if (entry.path().extension() != ".done") {
422423
continue;
423424
}

src/base/humanize.time.cc

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,31 @@ duration::to_string() const
151151

152152
const auto* curr_interval = intervals;
153153
auto usecs = to_us(this->d_timeval);
154-
auto millis = std::chrono::ceil<std::chrono::milliseconds>(usecs);
155154
std::string retval;
156155
bool neg = false;
157156

158-
if (millis < 0s) {
157+
if (usecs == 0us) {
158+
return retval;
159+
}
160+
161+
if (usecs < 0s) {
159162
neg = true;
160-
millis = -millis;
163+
usecs = -usecs;
164+
}
165+
166+
if (usecs < 1ms) {
167+
return fmt::format(FMT_STRING("{}us"), usecs.count());
161168
}
162169

163-
uint64_t remaining = millis.count();
170+
uint64_t remaining = usecs.count() / 1000;
164171
uint64_t scale = 1;
165172
if (this->d_msecs_resolution > 0) {
166173
remaining = roundup(remaining, this->d_msecs_resolution);
167174
}
168-
if (millis >= 10min) {
175+
if (usecs >= 10min) {
169176
remaining /= curr_interval->length;
170177
scale *= curr_interval->length;
171-
curr_interval += 1;
178+
++curr_interval;
172179
}
173180

174181
for (; curr_interval != std::end(intervals); curr_interval++) {

src/base/humanize.time.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#ifndef lnav_humanize_time_hh
3131
#define lnav_humanize_time_hh
3232

33+
#include <chrono>
3334
#include <optional>
3435
#include <string>
3536

@@ -78,7 +79,7 @@ public:
7879
return *this;
7980
}
8081

81-
std::string to_string() const;
82+
[[nodiscard]] std::string to_string() const;
8283

8384
private:
8485
explicit duration(const timeval& tv) : d_timeval(tv) {}

src/file_converter_manager.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ cleanup()
161161
auto now = std::filesystem::file_time_type::clock::now();
162162
auto cache_path = cache_dir();
163163
std::vector<std::filesystem::path> to_remove;
164+
std::error_code ec;
164165

165166
for (const auto& entry :
166-
std::filesystem::directory_iterator(cache_path))
167+
std::filesystem::directory_iterator(cache_path, ec))
167168
{
168169
auto mtime = std::filesystem::last_write_time(entry.path());
169170
auto exp_time = mtime + cfg.c_ttl;
@@ -176,7 +177,10 @@ cleanup()
176177

177178
for (auto& entry : to_remove) {
178179
log_debug("removing conversion: %s", entry.c_str());
179-
std::filesystem::remove_all(entry);
180+
std::filesystem::remove_all(entry, ec);
181+
if (ec) {
182+
log_error(" failed to remove: %s", ec.message().c_str());
183+
}
180184
}
181185
});
182186
}

src/piper.looper.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,10 @@ cleanup()
876876
const auto now = std::filesystem::file_time_type::clock::now();
877877
const auto& cache_path = storage_path();
878878
std::vector<std::filesystem::path> to_remove;
879+
std::error_code ec;
879880

880881
for (const auto& cache_subdir :
881-
std::filesystem::directory_iterator(cache_path))
882+
std::filesystem::directory_iterator(cache_path, ec))
882883
{
883884
auto mtime
884885
= std::filesystem::last_write_time(cache_subdir.path());
@@ -890,7 +891,7 @@ cleanup()
890891
bool is_recent = false;
891892

892893
for (const auto& entry :
893-
std::filesystem::directory_iterator(cache_subdir))
894+
std::filesystem::directory_iterator(cache_subdir, ec))
894895
{
895896
auto mtime = std::filesystem::last_write_time(entry.path());
896897
auto exp_time = mtime + cfg.c_ttl;

src/tailer/tailer.looper.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,10 +1197,11 @@ tailer::cleanup_cache()
11971197
auto cache_path = remote_cache_path();
11981198
const auto& cfg = injector::get<const config&>();
11991199
std::vector<std::filesystem::path> to_remove;
1200+
std::error_code ec;
12001201

12011202
log_debug("cache-ttl %d", cfg.c_cache_ttl.count());
12021203
for (const auto& entry :
1203-
std::filesystem::directory_iterator(cache_path))
1204+
std::filesystem::directory_iterator(cache_path, ec))
12041205
{
12051206
auto mtime = std::filesystem::last_write_time(entry.path());
12061207
auto exp_time = mtime + cfg.c_cache_ttl;

0 commit comments

Comments
 (0)