]> git.giacomolli.uk - onechat/commitdiff
Shorten the daemon log lines
authorAnderson A. Giacomolli <agiacomolli@gmail.com>
Mon, 9 Nov 2026 14:11:09 +0000 (11:11 -0300)
committerAnderson A. Giacomolli <agiacomolli@gmail.com>
Mon, 9 Nov 2026 14:11:09 +0000 (11:11 -0300)
Each log line names the event in a few plain words, then the cause after
a colon, such as "telegram: receive failed: 502 Bad Gateway (retry in
2s)" or "whatsapp: connected again after 1m25s". The lines no longer
explain what the event means for the user: they stay short enough to
read in the journal at a glance. A Telegram error gives the HTTP status
and its text without a prefix, because the telegram: prefix names the
service. The behavior of the logs does not change.

Issue: e4acfcb

16 files changed:
daemon.go
memory.go
memory_test.go
schedule.go
schedule_test.go
subagent_run.go
subagent_run_test.go
telegram.go
telegram_api.go
telegram_api_test.go
telegram_test.go
turn.go
turn_test.go
whatsapp.go
whatsapp_groups.go
whatsapp_test.go

index c2cf33b76c42d29cad022441c1f6c366bc7cce6b..a2893387ec3240423d6497b22bfcc4c8830e73f3 100644 (file)
--- a/daemon.go
+++ b/daemon.go
@@ -110,17 +110,17 @@ func daemon(ctx context.Context, out io.Writer) (err error) {
                return err
        }
 
-       linked := "WhatsApp is not linked"
+       linked := "WhatsApp not linked"
        if whatsapp.isLinked() {
-               linked = "WhatsApp is linked"
+               linked = "WhatsApp linked"
        }
 
-       logger.Printf("%s is ready: socket %s, model %s at %s effort, commands run in %s, %s, active schedules: %d", agent.config.Name, listener.Addr(), agent.config.Model, agent.config.Effort, agent.config.Workdir, linked, schedules.Len())
+       logger.Printf("ready: socket %s, model %s (%s), workdir %s, %s, %d schedules", listener.Addr(), agent.config.Model, agent.config.Effort, agent.config.Workdir, linked, schedules.Len())
 
        var telegram *TelegramBot
        if hasBot {
                telegram = newTelegramBot(newTelegramAPI(telegramAPIURL, botSettings.Token), botSettings.Owner, filepath.Join(agent.dir, telegramOffsetFileName), daemonLogger(out, "telegram: "))
-               logger.Print("the Telegram bot waits for messages of its owner")
+               logger.Print("Telegram bot started")
        }
 
        return daemonServe(ctx, listener, telegram, whatsapp, schedules, func(notify func(Event)) (*TurnLoop, error) {
index 751a5dc2ba205c3fa6684fc02f13412e933f24a2..5ea12b75a330292d37e26a361026f6e03510aa2e 100644 (file)
--- a/memory.go
+++ b/memory.go
@@ -583,7 +583,7 @@ func (m *Memory) run(key NodeKey, task Task) {
 
 // failed logs the failed build of the node key with its cause err.
 func (m *Memory) failed(key NodeKey, err error) {
-       m.logger.Printf("a summary of the chat failed, and it is tried again at the next message: node (%d, %d): %v", key.level, key.index, err)
+       m.logger.Printf("summary failed, retry at next message: node (%d, %d): %v", key.level, key.index, err)
 }
 
 // ready tells if both children of the node key are built and the node is not.
index ee932d1f36387b03132569f7f2b047b3b5f4f4e9..3930435aca7eb400699d43de8cd0c7c3f49f1192 100644 (file)
@@ -190,7 +190,7 @@ func TestMemorySettleFailsWhileABuildFailed(t *testing.T) {
        _, err = memory.Append("echo", memoryLongText(0))
        require.NoError(t, err)
        require.ErrorIs(t, memory.Settle(t.Context()), errMemoryUnsettled)
-       require.Equal(t, "a summary of the chat failed, and it is tried again at the next message: node (0, 0): fake failure\n", logs.String())
+       require.Equal(t, "summary failed, retry at next message: node (0, 0): fake failure\n", logs.String())
 
        summarizer.SetFailing(false)
        _, err = memory.Append("user", "retry")
index 9b95ce7a5722319630fa8bcf27fb0e8f8fc16511..3b4a4eed213055457193bcc5295b7a3783e9d463 100644 (file)
@@ -277,9 +277,9 @@ func (s *Schedules) deliver(ctx context.Context, l *TurnLoop) error {
                }
 
                if schedule.late(now) {
-                       s.logger.Printf("schedule %d runs %s late, because the daemon was stopped at its time", schedule.ID, durationText(now.Sub(schedule.Due)))
+                       s.logger.Printf("schedule %d ran %s late", schedule.ID, durationText(now.Sub(schedule.Due)))
                } else {
-                       s.logger.Printf("schedule %d runs", schedule.ID)
+                       s.logger.Printf("schedule %d ran", schedule.ID)
                }
 
                turns = append(turns, message)
index 96063aacae7611b4d8655473c8cff7b6ef3b2bea..ff7c905fca4b6590cc94c7c36b57e57a49fdef47 100644 (file)
@@ -258,7 +258,7 @@ func TestSchedulesRunStartsATurnWhenDue(t *testing.T) {
        require.Equal(t, "[Schedule 1] Sunday 2026-11-08 20:05 -03:00, once\nRemind the user to drink water.\n"+scheduleEmptyReply, texts[len(texts)-1])
        require.Equal(t, scheduleSource, test.events.LastEvent("work").Source)
        require.Equal(t, "No schedules.", schedules.List())
-       require.Equal(t, "schedule 1 runs\n", logs.String())
+       require.Equal(t, "schedule 1 ran\n", logs.String())
 }
 
 func TestSchedulesRunMissedSchedulesOnceAtTheStart(t *testing.T) {
@@ -284,7 +284,7 @@ func TestSchedulesRunMissedSchedulesOnceAtTheStart(t *testing.T) {
                "[Schedule 2] Sunday 2026-11-08 10:00 -03:00, repeats 0 * * * *\nTell the user the time.\n" + scheduleLateLine + "\n" + scheduleEmptyReply,
        }, texts[len(texts)-2:])
        require.Equal(t, "2 | Sunday 2026-11-08 21:00 -03:00 | 0 * * * * | Tell the user the time.", schedules.List())
-       require.Equal(t, "schedule 1 runs 11h30m0s late, because the daemon was stopped at its time\nschedule 2 runs 10h30m0s late, because the daemon was stopped at its time\n", logs.String())
+       require.Equal(t, "schedule 1 ran 11h30m0s late\nschedule 2 ran 10h30m0s late\n", logs.String())
 }
 
 func TestDaemonRunsADueSchedule(t *testing.T) {
index 7d3687c48f08691aed53f590dab7d10023e39e34..ca4ebd4247fd3038cd8a9902ad2ea77482d3872c 100644 (file)
@@ -240,7 +240,7 @@ func (r *SubagentRuns) Resume(ctx context.Context) error {
        for _, name := range names {
                _, err = r.Tell(ctx, name, text)
                if err != nil {
-                       r.logger.Printf("subagent %s cannot go on after the restart, and its report tells the agent: %v", name, err)
+                       r.logger.Printf("subagent %s lost at restart: %v", name, err)
                        r.report(name, subagentReport(name, []string{"failed: " + err.Error()}), subagentFailed)
                }
        }
@@ -455,11 +455,11 @@ func (r *SubagentRuns) run(ctx context.Context, run *SubagentRun) {
 
        switch status {
        case subagentStopped:
-               r.logger.Printf("subagent %s is stopped by the user", run.subagent.name)
+               r.logger.Printf("subagent %s stopped", run.subagent.name)
        case subagentFailed:
-               r.logger.Printf("subagent %s failed, and its report tells the agent: %v", run.subagent.name, failure)
+               r.logger.Printf("subagent %s failed: %v", run.subagent.name, failure)
        default:
-               r.logger.Printf("subagent %s is done, and its report goes to the agent", run.subagent.name)
+               r.logger.Printf("subagent %s done", run.subagent.name)
        }
 
        r.report(run.subagent.name, subagentReport(run.subagent.name, replies), status)
index d784b8968431989989ead0ceba2e8a8b69de7c73..125ca332cf12c94c3df00c4e994858735e6cc525 100644 (file)
@@ -66,7 +66,7 @@ func TestSpawnRunsASubagentInTheBackground(t *testing.T) {
                Source: name,
                Status: subagentFinished,
        }, test.events.LastEvent("work"))
-       require.Equal(t, "subagent "+name+" is done, and its report goes to the agent\n", test.logs.String())
+       require.Equal(t, "subagent "+name+" done\n", test.logs.String())
 
        var first, second *ModelFakeCall
        for n := range server.Calls() {
@@ -189,7 +189,7 @@ func TestFullContextGivesAFailedReport(t *testing.T) {
                "reply: It failed.",
        }, test.Log(t))
        require.Equal(t, subagentFailed, test.events.LastEvent("work").Status)
-       require.Equal(t, "subagent "+name+" failed, and its report tells the agent: model call: HTTP 400: "+subagentTestFullContext+"\n", test.logs.String())
+       require.Equal(t, "subagent "+name+" failed: model call: HTTP 400: "+subagentTestFullContext+"\n", test.logs.String())
 }
 
 func TestSubagentHasItsOwnEffortAndNoSpawn(t *testing.T) {
@@ -374,7 +374,7 @@ func TestStopEndsASubagentAndItsCommand(t *testing.T) {
                "work: " + subagentReport(name, []string{"stopped"}),
        }, test.Log(t))
        require.Equal(t, subagentStopped, test.events.LastEvent("work").Status)
-       require.Equal(t, "subagent "+name+" is stopped by the user\n", test.logs.String())
+       require.Equal(t, "subagent "+name+" stopped\n", test.logs.String())
 
        log, err := subagent.Show()
        require.NoError(t, err)
index 9d7600fd44d89eef4f14340a5fc270208092ea77..af1b91e8a899aa8ef1f54f6344844574693eed91 100644 (file)
@@ -262,8 +262,8 @@ func (b *TelegramBot) poll(ctx context.Context, l *TurnLoop, whatsapp *WhatsApp)
 
        outage := &TelegramOutage{
                logger: b.logger,
-               loss:   "cannot get messages from Telegram",
-               back:   "messages from Telegram come again",
+               loss:   "receive failed",
+               back:   "receive back",
        }
 
        wait := b.minWait
@@ -371,7 +371,7 @@ func (b *TelegramBot) pause(ctx context.Context, outage *TelegramOutage, err err
 func (b *TelegramBot) handle(ctx context.Context, l *TurnLoop, whatsapp *WhatsApp, update TelegramUpdate) error {
        message := update.Message
        if message == nil || message.Chat.Type != "private" || message.Chat.ID != b.owner || message.From == nil || message.From.ID != b.owner {
-               b.logger.Print("a Telegram message is ignored, because it is not from the owner in the private chat")
+               b.logger.Print("message ignored: not from the owner")
                return nil
        }
 
@@ -430,14 +430,14 @@ func (b *TelegramBot) deliver(ctx context.Context, part TelegramPart) {
 
                var answer *TelegramError
                if len(part.entities) > 0 && errors.As(err, &answer) && answer.Status == http.StatusBadRequest {
-                       b.logger.Printf("a reply goes as plain text, because Telegram refused its formatting: %v", err)
+                       b.logger.Printf("reply sent as plain text: %v", err)
                        part.entities = nil
 
                        continue
                }
 
                if !retry {
-                       b.logger.Printf("a reply to Telegram is lost: %v", err)
+                       b.logger.Printf("reply lost: %v", err)
                        return
                }
 
@@ -467,7 +467,7 @@ func (b *TelegramBot) deliverRich(ctx context.Context, markdown string) {
                }
 
                if telegramRejected(err) {
-                       b.logger.Printf("a reply goes with simpler formatting, because Telegram refused its full formatting: %v", err)
+                       b.logger.Printf("reply sent with simple formatting: %v", err)
                        for _, part := range telegramReplyParts(telegramUnescapeTags(markdown)) {
                                b.deliver(ctx, part)
                        }
@@ -476,7 +476,7 @@ func (b *TelegramBot) deliverRich(ctx context.Context, markdown string) {
                }
 
                if !retry {
-                       b.logger.Printf("a reply to Telegram is lost: %v", err)
+                       b.logger.Printf("reply lost: %v", err)
                        return
                }
 
@@ -488,8 +488,8 @@ func (b *TelegramBot) deliverRich(ctx context.Context, markdown string) {
 func (b *TelegramBot) sendOutage() *TelegramOutage {
        return &TelegramOutage{
                logger: b.logger,
-               loss:   "cannot send replies to Telegram",
-               back:   "replies go to Telegram again",
+               loss:   "send failed",
+               back:   "send back",
        }
 }
 
@@ -519,7 +519,7 @@ func (o *TelegramOutage) Fail(err error, delay time.Duration) {
        }
 
        o.start = time.Now()
-       o.logger.Printf("%s: %v (next try in %s)", o.loss, err, durationText(delay))
+       o.logger.Printf("%s: %v (retry in %s)", o.loss, err, durationText(delay))
 }
 
 // End logs the end of the outage that runs, with its length.
@@ -528,7 +528,7 @@ func (o *TelegramOutage) End() {
                return
        }
 
-       o.logger.Printf("%s, after %s", o.back, durationText(time.Since(o.start)))
+       o.logger.Printf("%s after %s", o.back, durationText(time.Since(o.start)))
        o.start = time.Time{}
 }
 
index 24f02ac344954b52f752947f64feeba107c1d7a6..7b9457f6d207dc6abeb03fcd926e6ed5916d4aff 100644 (file)
@@ -163,7 +163,7 @@ func (b *TelegramAPI) call(ctx context.Context, timeout time.Duration, method st
        data, err := io.ReadAll(io.LimitReader(response.Body, telegramAnswerBytes))
        err = errors.Join(err, response.Body.Close())
        if err != nil {
-               return b.networkError("the answer broke off", err, timeout)
+               return b.networkError("answer cut off", err, timeout)
        }
 
        var answer TelegramAnswer
@@ -176,7 +176,7 @@ func (b *TelegramAPI) call(ctx context.Context, timeout time.Duration, method st
        }
 
        if err != nil {
-               return b.networkError("the answer is not valid JSON", err, timeout)
+               return b.networkError("invalid JSON", err, timeout)
        }
 
        if !answer.OK {
@@ -194,7 +194,7 @@ func (b *TelegramAPI) call(ctx context.Context, timeout time.Duration, method st
 
        err = json.Unmarshal(answer.Result, result)
        if err != nil {
-               return b.networkError("the result is not valid", err, timeout)
+               return b.networkError("invalid result", err, timeout)
        }
 
        return nil
@@ -240,10 +240,10 @@ func (e *TelegramNetworkError) Error() string {
 }
 
 // TelegramError is an answer of the Bot API that tells of a failure. Its text
-// gives the HTTP status and the description, such as "Telegram answered 502 Bad
-// Gateway". RetryAfter is the wait that the Bot API asks for after HTTP 429.
-// Refused tells that the answer is a Bot API answer with ok false, not a page
-// of a proxy or of a server error.
+// gives the HTTP status and the description, such as "502 Bad Gateway".
+// RetryAfter is the wait that the Bot API asks for after HTTP 429. Refused
+// tells that the answer is a Bot API answer with ok false, not a page of a
+// proxy or of a server error.
 type TelegramError struct {
        Status      int
        Description string
@@ -252,7 +252,7 @@ type TelegramError struct {
 }
 
 func (e *TelegramError) Error() string {
-       return fmt.Sprintf("Telegram answered %d %s", e.Status, e.Description)
+       return fmt.Sprintf("%d %s", e.Status, e.Description)
 }
 
 // TelegramUpdate is one update of getUpdates. Message is nil for the kinds of
index f789101a2bf6a86e15ac226258ef60900fb4c80c..9b66aa45937984a3b9397332974e7e75aefff1aa 100644 (file)
@@ -159,7 +159,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                        },
                        retry:     true,
                        wait:      3 * time.Second,
-                       errorText: "answered 429",
+                       errorText: "429",
                },
                {
                        name: "server error page is retried",
@@ -168,7 +168,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                                _, _ = io.WriteString(w, "<html>bad gateway</html>")
                        },
                        retry:     true,
-                       errorText: "Telegram answered 502 Bad Gateway",
+                       errorText: "502 Bad Gateway",
                },
                {
                        name: "token echoed in a description is hidden",
@@ -187,7 +187,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                        },
                        retry:     false,
                        rejected:  true,
-                       errorText: "answered 400 Bad Request: can't parse",
+                       errorText: "400 Bad Request: can't parse",
                },
                {
                        name: "unknown method is a refusal",
@@ -197,7 +197,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                        },
                        retry:     false,
                        rejected:  true,
-                       errorText: "answered 404 Not Found",
+                       errorText: "404 Not Found",
                },
                {
                        name: "not found page of a proxy is not a refusal",
@@ -206,7 +206,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                                _, _ = io.WriteString(w, "<html>not found</html>")
                        },
                        retry:     false,
-                       errorText: "answered 404 Not Found",
+                       errorText: "404 Not Found",
                },
                {
                        name: "broken answer is retried",
@@ -214,7 +214,7 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                                _, _ = io.WriteString(w, `{"ok":`)
                        },
                        retry:     true,
-                       errorText: "not valid JSON",
+                       errorText: "invalid JSON",
                },
        }
 
index 4d2a9e64feb9bbe48665253365858a1082bf36db..48e550392fee45ad3f8ceef0e7e02cb6deeb0372 100644 (file)
@@ -76,7 +76,7 @@ func TestBotIgnoresEveryoneButTheOwner(t *testing.T) {
        require.Empty(t, telegram.Sent())
        require.NotContains(t, terminal.Output(), "secret")
        require.NotContains(t, logs.String(), "secret")
-       require.Contains(t, logs.String(), "a Telegram message is ignored")
+       require.Contains(t, logs.String(), "message ignored")
 }
 
 func TestBotAnswersThatOnlyTextIsSupported(t *testing.T) {
@@ -266,8 +266,8 @@ func TestBotTriesAgainAfterFailures(t *testing.T) {
        })
 
        telegramWaitForSent(t, telegram, "ok")
-       require.Contains(t, logs.String(), "answered 502")
-       require.Contains(t, logs.String(), "answered 429")
+       require.Contains(t, logs.String(), "502")
+       require.Contains(t, logs.String(), "429")
        require.NotContains(t, logs.String(), telegramTestToken)
 }
 
@@ -292,8 +292,8 @@ func TestDeliverTriesAgainAfterATimeout(t *testing.T) {
 
        require.Equal(t, []string{"hello"}, telegram.Sent())
        require.Len(t, telegram.Calls(), 2)
-       require.Contains(t, logs.String(), "cannot send replies to Telegram: no answer in 50ms (next try in 1ms)\n")
-       require.Contains(t, logs.String(), "replies go to Telegram again, after ")
+       require.Contains(t, logs.String(), "send failed: no answer in 50ms (retry in 1ms)\n")
+       require.Contains(t, logs.String(), "send back after ")
        require.Equal(t, 2, strings.Count(logs.String(), "\n"))
        require.NotContains(t, logs.String(), telegramTestToken)
 }
@@ -375,7 +375,7 @@ func TestRichMessageFailures(t *testing.T) {
                        methods: []string{"sendRichMessage", "sendMessage"},
                        sent:    []string{"a secret word"},
                        lines:   1,
-                       logText: "Telegram refused its full formatting",
+                       logText: "reply sent with simple formatting",
                },
                {
                        name:    "unknown method sends the reply once with entities",
@@ -384,7 +384,7 @@ func TestRichMessageFailures(t *testing.T) {
                        methods: []string{"sendRichMessage", "sendMessage"},
                        sent:    []string{"a secret word"},
                        lines:   1,
-                       logText: "Telegram refused its full formatting",
+                       logText: "reply sent with simple formatting",
                },
                {
                        name:    "rate limit tries the rich message again",
@@ -392,7 +392,7 @@ func TestRichMessageFailures(t *testing.T) {
                        methods: []string{"sendRichMessage", "sendRichMessage"},
                        sent:    []string{"a **secret** word"},
                        lines:   2,
-                       logText: "cannot send replies to Telegram: Telegram answered 429",
+                       logText: "send failed: 429",
                },
                {
                        name:    "server error tries the rich message again",
@@ -400,7 +400,7 @@ func TestRichMessageFailures(t *testing.T) {
                        methods: []string{"sendRichMessage", "sendRichMessage"},
                        sent:    []string{"a **secret** word"},
                        lines:   2,
-                       logText: "cannot send replies to Telegram: Telegram answered 500",
+                       logText: "send failed: 500",
                },
                {
                        name:    "other refusal drops the reply",
@@ -408,7 +408,7 @@ func TestRichMessageFailures(t *testing.T) {
                        always:  true,
                        methods: []string{"sendRichMessage"},
                        lines:   1,
-                       logText: "a reply to Telegram is lost: Telegram answered 403",
+                       logText: "reply lost: 403",
                },
        }
 
@@ -595,7 +595,7 @@ func TestRefusedEntitiesGoAgainAsPlainText(t *testing.T) {
        require.Nil(t, calls[1].params["entities"])
        require.Equal(t, []string{"a secret word"}, telegram.Sent())
        require.Equal(t, 1, strings.Count(logs.String(), "\n"))
-       require.Contains(t, logs.String(), "a reply goes as plain text, because Telegram refused its formatting")
+       require.Contains(t, logs.String(), "reply sent as plain text")
        require.NotContains(t, logs.String(), telegramTestToken)
        require.NotContains(t, logs.String(), "secret word")
 }
@@ -608,7 +608,7 @@ func TestBotLogsNoTokenWhenTheNetworkFails(t *testing.T) {
        daemonStartTestWithBot(t, newModelFake(t), bot)
 
        require.Eventually(t, func() bool {
-               return strings.Contains(logs.String(), "cannot get messages from Telegram: no answer: ")
+               return strings.Contains(logs.String(), "receive failed: no answer: ")
        }, 10*time.Second, time.Millisecond)
        require.NotContains(t, logs.String(), telegramTestToken)
 }
@@ -642,8 +642,8 @@ func TestBotLogsAnOutageOnlyAtItsStartAndEnd(t *testing.T) {
        telegramWaitForSent(t, telegram, "ok")
        lines := strings.Split(strings.TrimSuffix(logs.String(), "\n"), "\n")
        require.Len(t, lines, 2)
-       require.Equal(t, "cannot get messages from Telegram: Telegram answered 502 Bad Gateway (next try in 1ms)", lines[0])
-       require.Regexp(t, `^messages from Telegram come again, after [0-9]+m?s$`, lines[1])
+       require.Equal(t, "receive failed: 502 Bad Gateway (retry in 1ms)", lines[0])
+       require.Regexp(t, `^receive back after [0-9]+m?s$`, lines[1])
        require.NotContains(t, logs.String(), "secret word")
        require.NotContains(t, logs.String(), strconv.FormatInt(telegramTestOwner, 10))
 }
diff --git a/turn.go b/turn.go
index e490068659da9fc4194a4f6eeb04a851ac464dee..40645b100ca8fb3aca74d8a064eed4110c890a07 100644 (file)
--- a/turn.go
+++ b/turn.go
@@ -329,7 +329,7 @@ func (l *TurnLoop) turn(ctx context.Context) error {
        err := l.chain(ctx)
        if err != nil && !errors.Is(err, errChainLogWrite) {
                if ctx.Err() == nil {
-                       l.logger.Printf("the turn stops before its end, and the agent waits for the next message: %v", err)
+                       l.logger.Printf("turn failed: %v", err)
                }
 
                l.notify(Event{
index 4f29cd4454ecec8a48d1b9878d29b7566b14a1b0..9bb0e995d5b66393d8c5b46fdeb2480e50e8a233 100644 (file)
@@ -222,7 +222,7 @@ func TestFailedCallEndsTheTurnWithoutARetry(t *testing.T) {
        require.Equal(t, 1, server.Calls())
        require.Contains(t, test.events.Last("error"), "HTTP 503")
        require.Equal(t, 1, strings.Count(test.logs.String(), "\n"))
-       require.Contains(t, test.logs.String(), "the turn stops before its end, and the agent waits for the next message: ")
+       require.Contains(t, test.logs.String(), "turn failed: ")
        require.Contains(t, test.logs.String(), "HTTP 503")
        require.NotContains(t, test.logs.String(), "hello")
 }
index 2c1b6cb9aaa70e327fd4a342d282fb97ecd4a247..40729d83b044e8ca1303c2a1b08a10786d587e40 100644 (file)
@@ -405,7 +405,7 @@ func (w *WhatsApp) connect(ctx context.Context) {
 
        err := client.ConnectContext(ctx)
        if err != nil {
-               w.logger.Printf("WhatsApp messages do not come, because the connection failed, and it is tried again only at a restart of the daemon: %s", w.redact(err.Error()))
+               w.logger.Printf("connect failed, restart to retry: %s", w.redact(err.Error()))
        }
 }
 
@@ -435,7 +435,7 @@ func (w *WhatsApp) loggedOut(ctx context.Context, l *TurnLoop) error {
                return nil
        }
 
-       w.logger.Print("WhatsApp messages stop, because the phone logged out this device (run /whatsapp pair PHONE to link it again)")
+       w.logger.Print("logged out by the phone, run /whatsapp pair PHONE")
        err := w.inbox.deliver(ctx, l, w.link(), true)
        if err != nil {
                return err
@@ -443,12 +443,12 @@ func (w *WhatsApp) loggedOut(ctx context.Context, l *TurnLoop) error {
 
        err = w.removeSession()
        if err != nil {
-               w.logger.Printf("the session of the logged out device stays on the disk, because its delete failed: %v", err)
+               w.logger.Printf("session delete failed: %v", err)
        }
 
        err = l.note("WhatsApp was unlinked from the phone.")
        if err != nil {
-               w.logger.Printf("the chat has no note of the logout, because its write failed: %v", err)
+               w.logger.Printf("chat note failed: %v", err)
        }
 
        w.broadcast("WhatsApp was unlinked from the phone. Run /whatsapp pair PHONE to link it again.")
@@ -491,10 +491,10 @@ func (w *WhatsApp) unlink(ctx context.Context, l *TurnLoop, answer func(text str
                return nil
        }
 
-       w.logger.Print("WhatsApp messages stop, because the user unlinked WhatsApp")
+       w.logger.Print("unlinked")
        err = l.note("WhatsApp is unlinked.")
        if err != nil {
-               w.logger.Printf("the chat has no note of the unlink, because its write failed: %v", err)
+               w.logger.Printf("chat note failed: %v", err)
        }
 
        if client == nil || logoutErr != nil {
@@ -631,11 +631,11 @@ func (w *WhatsApp) pair(ctx, runCtx context.Context, l *TurnLoop, phone string,
                case item.Event == whatsmeow.QRChannelSuccess.Event:
                        linked = true
                        w.linkedBy(client)
-                       w.logger.Print("WhatsApp is linked")
+                       w.logger.Print("linked")
 
                        err = l.note("WhatsApp is linked.")
                        if err != nil {
-                               w.logger.Printf("the chat has no note of the link, because its write failed: %v", err)
+                               w.logger.Printf("chat note failed: %v", err)
                        }
 
                        answer("WhatsApp is linked to +" + phone + ".")
@@ -732,9 +732,9 @@ func (w *WhatsApp) handle(event any) bool {
                switch {
                case !w.linked || w.connected:
                case w.disconnectedAt.IsZero():
-                       line = "WhatsApp is connected, and new messages come in"
+                       line = "connected"
                default:
-                       line = "WhatsApp is connected again, after " + durationText(w.clock().Sub(w.disconnectedAt))
+                       line = "connected again after " + durationText(w.clock().Sub(w.disconnectedAt))
                }
 
                w.connected = true
@@ -749,9 +749,9 @@ func (w *WhatsApp) handle(event any) bool {
                }
        case *events.Disconnected:
                if w.linked && (w.connected || w.disconnectedAt.IsZero()) {
-                       line = "new WhatsApp messages wait, because the connection is lost (the next try is automatic)"
+                       line = "disconnected, retrying"
                        if !w.connected {
-                               line = "new WhatsApp messages wait, because the first connection failed (the next try is automatic)"
+                               line = "first connect failed, retrying"
                        }
 
                        w.disconnectedAt = w.clock()
@@ -773,7 +773,7 @@ func (w *WhatsApp) handle(event any) bool {
                        w.connected = false
                        w.noticed = true
                        notice = "WhatsApp is disconnected and does not connect again by itself: " + event.PermanentDisconnectDescription() + ". Restart the daemon to try again."
-                       line = "WhatsApp messages do not come, because the connection is lost and it is tried again only at a restart of the daemon: " + whatsappRedact(w.own, event.PermanentDisconnectDescription())
+                       line = "disconnected for good, restart to retry: " + whatsappRedact(w.own, event.PermanentDisconnectDescription())
                }
        }
 
index e8111c30864e278bcdcfac07c2654c2ce6bc1cba..c8d066a510188877584e1849f6a0a2299fef0289 100644 (file)
@@ -80,7 +80,7 @@ func (g *WhatsAppGroups) read(ctx context.Context, link WhatsAppLink) bool {
 
        groups, err := link.client.GetJoinedGroups(ctx)
        if err != nil {
-               g.logger.Printf("group names can be missing, because the list of groups did not load: %s", whatsappRedact(link.own, err.Error()))
+               g.logger.Printf("group list failed: %s", whatsappRedact(link.own, err.Error()))
        }
 
        g.mutex.Lock()
index 5c38d59123714b757bea6d4d330d1672fed0ab60..7001ea1145b543d317a986d007e51a4f99e2b18e 100644 (file)
@@ -43,7 +43,7 @@ func TestWhatsAppStatusOfAFirstConnectionThatFailed(t *testing.T) {
        <-fake.connects
        require.True(t, fake.Emit(&events.Disconnected{}))
        require.Equal(t, "WhatsApp is linked and disconnected since 2026-01-01 12:00.", whatsapp.Status())
-       require.Equal(t, "new WhatsApp messages wait, because the first connection failed (the next try is automatic)\n", logs.String())
+       require.Equal(t, "first connect failed, retrying\n", logs.String())
 }
 
 func TestWhatsAppLogsEachChangeOfTheConnectionOnce(t *testing.T) {
@@ -63,9 +63,9 @@ func TestWhatsAppLogsEachChangeOfTheConnectionOnce(t *testing.T) {
        require.True(t, fake.Emit(&events.Connected{}))
 
        require.Equal(t, []string{
-               "WhatsApp is connected, and new messages come in",
-               "new WhatsApp messages wait, because the connection is lost (the next try is automatic)",
-               "WhatsApp is connected again, after 1m25s",
+               "connected",
+               "disconnected, retrying",
+               "connected again after 1m25s",
        }, strings.Split(strings.TrimSuffix(logs.String(), "\n"), "\n"))
        require.NotContains(t, logs.String(), whatsappTestNumber)
        require.NotContains(t, logs.String(), whatsappTestLID)
@@ -396,7 +396,7 @@ func TestWhatsAppLogsNoOwnNumber(t *testing.T) {
        require.Eventually(t, func() bool {
                return logs.String() != ""
        }, 10*time.Second, time.Millisecond)
-       require.Equal(t, "WhatsApp messages do not come, because the connection failed, and it is tried again only at a restart of the daemon: no route for OWN@s.whatsapp.net and OWN@lid\n", logs.String())
+       require.Equal(t, "connect failed, restart to retry: no route for OWN@s.whatsapp.net and OWN@lid\n", logs.String())
 }
 
 func TestWhatsAppPhone(t *testing.T) {