diff options
| author | Castor Gemini <[email protected]> | 2025-08-22 03:26:39 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-08-22 03:26:39 -0500 |
| commit | f6e881b064e0cfec382fc7fc08af334d64473849 (patch) | |
| tree | e7671882352553227acc94eb36f54859760c3cbf /doPlayback.go | |
| parent | dc2b0eeb06406f44997d8eb7e0553e3fc34e0d85 (diff) | |
refactor(playback): Move formatting logic to prettyFormat.go
- Create a new prettyFormat.go file to contain all the detailed
log formatting and printing logic.
- Simplify doPlayback.go to handle the summary view and call out
to the new prettyFormatChat function for detailed views.
- This separation of concerns makes the code cleaner and fixes
compilation errors related to redeclared functions.
Diffstat (limited to 'doPlayback.go')
| -rw-r--r-- | doPlayback.go | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/doPlayback.go b/doPlayback.go index 94fd82d..9ece30e 100644 --- a/doPlayback.go +++ b/doPlayback.go @@ -11,25 +11,20 @@ func doPlayback() { showChat(argv.Playback.Uuid) return } + log.Infof("Found %d chat topic(s) in the log.", len(me.chats.GetChats())) fmt.Println("-------------------------------------------------") - // Iterate through the top-level Chat messages, which are now named groups. for _, chat := range me.chats.GetChats() { - - // Get the number of entries in the chat. entryCount := len(chat.GetEntries()) - - // Get the timestamp of the first entry to represent the chat's start time. var formattedTime string - if entryCount > 0 && chat.GetEntries()[0].GetCtime() != nil { - t := chat.GetEntries()[0].GetCtime().AsTime() - formattedTime = t.Format("2006-01-02 15:04:05") // YYYY-MM-DD HH:MM:SS + if ctime := chat.GetCtime(); ctime != nil { + t := ctime.AsTime() + formattedTime = t.Format("2006-01-02 15:04:05") } else { formattedTime = "No Timestamp" } - // Print the formatted one-line summary. fmt.Printf("Topic: %-25s | Entries: %-4d | Started: %s | UUID: %s\n", chat.GetChatName(), entryCount, @@ -46,6 +41,6 @@ func showChat(uuid string) { log.Info("unknown uuid", uuid) return } - log.Info("uuid was found ok", uuid) - // TODO: show the chat entries here + // Call the new, dedicated formatting function. + prettyFormatChat(chat) } |
