logtree: implement raw logging

Test Plan: Covered by new tests.

X-Origin-Diff: phab/D640
GitOrigin-RevId: 786ab2851710bf2819dcb91571b3567e8da3e377
diff --git a/core/pkg/logtree/journal_entry.go b/core/pkg/logtree/journal_entry.go
index 58b21f5..bc65ef3 100644
--- a/core/pkg/logtree/journal_entry.go
+++ b/core/pkg/logtree/journal_entry.go
@@ -16,6 +16,8 @@
 
 package logtree
 
+import "git.monogon.dev/source/nexantic.git/core/pkg/logbuffer"
+
 // entry is a journal entry, representing a single log event (encompassed in a Payload) at a given DN.
 // See the journal struct for more information about the global/local linked lists.
 type entry struct {
@@ -24,8 +26,11 @@
 	// journal is the parent journal of this entry. An entry can belong only to a single journal. This pointer is used
 	// to mutate the journal's head/tail pointers when unlinking an entry.
 	journal *journal
-	// payload is the inner log entry LeveledPayload. It contains all data and metadata received from the log producer.
+	// leveled is the leveled log entry for this entry, if this log entry was emitted by leveled logging. Otherwise it
+	// is nil.
 	leveled *LeveledPayload
+	// raw is the raw log entry for this entry, if this log entry was emitted by raw logging. Otherwise it is nil.
+	raw *logbuffer.Line
 
 	// prevGlobal is the previous entry in the global linked list, or nil if this entry is the oldest entry in the
 	// global linked list.
@@ -48,6 +53,16 @@
 	seqLocal uint64
 }
 
+// external returns a LogEntry object for this entry, ie. the public version of this object, without fields relating to
+// the parent journal, linked lists, sequences, etc. These objects are visible to library consumers.
+func (e *entry) external() *LogEntry {
+	return &LogEntry{
+		DN:      e.origin,
+		Leveled: e.leveled,
+		Raw:     e.raw,
+	}
+}
+
 // unlink removes this entry from both global and local linked lists, updating the journal's head/tail pointers if
 // needed.
 // journal.mu must be taken as RW