summaryrefslogtreecommitdiffstats
path: root/src/logfile.hh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/logfile.hh58
1 files changed, 49 insertions, 9 deletions
diff --git a/src/logfile.hh b/src/logfile.hh
index 8c711a0..e936e79 100644
--- a/src/logfile.hh
+++ b/src/logfile.hh
@@ -1,4 +1,3 @@
-
/**
* Copyright (c) 2007-2012, Timothy Stack
*
@@ -49,6 +48,7 @@
#include "base/result.h"
#include "bookmarks.hh"
#include "byte_array.hh"
+#include "file_options.hh"
#include "ghc/filesystem.hpp"
#include "line_buffer.hh"
#include "log_format_fwd.hh"
@@ -114,7 +114,9 @@ public:
* descriptor needs to be seekable.
*/
static Result<std::shared_ptr<logfile>, std::string> open(
- std::string filename, logfile_open_options& loo);
+ ghc::filesystem::path filename,
+ const logfile_open_options& loo,
+ auto_fd fd = auto_fd{});
~logfile() override;
@@ -126,7 +128,10 @@ public:
}
/** @return The filename as given in the constructor. */
- const std::string& get_filename() const { return this->lf_filename; }
+ const ghc::filesystem::path& get_filename() const
+ {
+ return this->lf_filename;
+ }
/** @return The filename as given in the constructor, excluding the path
* prefix. */
@@ -146,6 +151,11 @@ public:
bool is_compressed() const { return this->lf_line_buffer.is_compressed(); }
+ bool has_line_metadata() const
+ {
+ return this->lf_line_buffer.has_line_metadata();
+ }
+
bool is_valid_filename() const { return this->lf_valid_filename; }
file_off_t get_index_size() const { return this->lf_index_size; }
@@ -164,6 +174,8 @@ public:
text_format_t get_text_format() const { return this->lf_text_format; }
+ void set_text_format(text_format_t tf) { this->lf_text_format = tf; }
+
/**
* @return The last modified time of the file when the file was last
* indexed.
@@ -188,13 +200,18 @@ public:
this->adjust_content_time(-1, tv);
}
- void mark_as_duplicate(const std::string& name);
+ bool mark_as_duplicate(const std::string& name);
const logfile_open_options& get_open_options() const
{
return this->lf_options;
}
+ void set_include_in_session(bool enabled)
+ {
+ this->lf_options.with_include_in_session(enabled);
+ }
+
void reset_state();
bool is_time_adjusted() const
@@ -240,6 +257,8 @@ public:
Result<std::string, std::string> read_file();
+ Result<shared_buffer_ref, std::string> read_range(file_range fr);
+
iterator line_base(iterator ll)
{
auto retval = ll;
@@ -283,6 +302,11 @@ public:
};
}
+ file_off_t get_line_content_offset(const_iterator ll)
+ {
+ return ll->get_offset() + (this->lf_line_buffer.is_piper() ? 22 : 0);
+ }
+
void read_full_message(const_iterator ll,
shared_buffer_ref& msg_out,
int max_lines = 50);
@@ -337,6 +361,8 @@ public:
bool is_indexing() const { return this->lf_indexing; }
+ void set_indexing(bool val) { this->lf_indexing = val; }
+
/** Check the invariants for this object. */
bool invariant()
{
@@ -358,9 +384,9 @@ public:
note_map get_notes() const { return *this->lf_notes.readAccess(); }
- using safe_opid_map = safe::Safe<log_opid_map>;
+ using safe_opid_state = safe::Safe<log_opid_state>;
- safe_opid_map& get_opids() { return this->lf_opids; }
+ safe_opid_state& get_opids() { return this->lf_opids; }
void quiesce() { this->lf_line_buffer.quiesce(); }
@@ -384,6 +410,12 @@ public:
return this->lf_embedded_metadata;
}
+ nonstd::optional<std::pair<std::string, lnav::file_options>>
+ get_file_options() const
+ {
+ return this->lf_file_options;
+ }
+
protected:
/**
* Process a line from the file.
@@ -399,9 +431,11 @@ protected:
void set_format_base_time(log_format* lf);
private:
- logfile(std::string filename, logfile_open_options& loo);
+ logfile(ghc::filesystem::path filename, const logfile_open_options& loo);
+
+ bool file_options_have_changed();
- std::string lf_filename;
+ ghc::filesystem::path lf_filename;
logfile_open_options lf_options;
logfile_activity lf_activity;
bool lf_named_file{true};
@@ -423,13 +457,14 @@ private:
bool lf_is_closed{false};
bool lf_indexing{true};
bool lf_partial_line{false};
+ bool lf_zoned_to_local_state{true};
logline_observer* lf_logline_observer{nullptr};
logfile_observer* lf_logfile_observer{nullptr};
size_t lf_longest_line{0};
text_format_t lf_text_format{text_format_t::TF_UNKNOWN};
uint32_t lf_out_of_time_order_count{0};
safe_notes lf_notes;
- safe_opid_map lf_opids;
+ safe_opid_state lf_opids;
size_t lf_watch_count{0};
ArenaAlloc::Alloc<char> lf_allocator{64 * 1024};
nonstd::optional<time_t> lf_cached_base_time;
@@ -440,7 +475,12 @@ private:
robin_hood::unordered_map<uint32_t, bookmark_metadata> lf_bookmark_metadata;
std::vector<std::shared_ptr<format_tag_def>> lf_applicable_taggers;
+ std::vector<std::shared_ptr<format_partition_def>>
+ lf_applicable_partitioners;
std::map<std::string, metadata> lf_embedded_metadata;
+ size_t lf_file_options_generation{0};
+ nonstd::optional<std::pair<std::string, lnav::file_options>>
+ lf_file_options;
};
class logline_observer {