@ 261101.7

261026.37 · 21085a84dd5a7256f0a1f09b4f390e35ab0d43c6

Under systemd a line is logged once

--restart and failures log a line and print it on stderr. A unit's stderr is the journal, so each line showed twice there. Where JOURNAL_STREAM names stderr, www now only logs it.

reading declarations

Changes to log_test.go. All files

log_test.go

@@ -3,10 +3,12 @@ package main import ( 	"bytes" 	"encoding/binary"+	"fmt" 	"net" 	"os" 	"path/filepath" 	"strings"+	"syscall" 	"testing" 	"time" )@@ -175,3 +177,24 @@ func TestRequestLogShared(t *testing.T) { 		t.Errorf("shared log lacks the visitor:\n%s", b) 	} }++// Under systemd, stderr is the journal, so what is logged is not printed+// as well.+func TestStderrIsJournal(t *testing.T) {+	var st syscall.Stat_t+	if err := syscall.Fstat(2, &st); err != nil {+		t.Skip(err)+	}+	t.Setenv("JOURNAL_STREAM", fmt.Sprintf("%d:%d", st.Dev, st.Ino))+	if !stderrIsJournal() {+		t.Error("stderr's own device and inode are not the journal")+	}+	t.Setenv("JOURNAL_STREAM", fmt.Sprintf("%d:%d", st.Dev, st.Ino+1))+	if stderrIsJournal() {+		t.Error("another inode is the journal")+	}+	t.Setenv("JOURNAL_STREAM", "")+	if stderrIsJournal() {+		t.Error("no JOURNAL_STREAM is the journal")+	}+}