logger: NewFromWriter should accept io.Writer instead of *os.File #177

Closed
opened 2026-07-06 07:23:06 +00:00 by the.auditor · 0 comments
Owner

logging.NewFromWriter(w *os.File) takes a concrete *os.File type, but the underlying log.New() accepts io.Writer. Restricting to *os.File prevents using other writers (e.g., bytes.Buffer for tests, network connections).

Suggested fix: Change the parameter type to io.Writer:

func NewFromWriter(w io.Writer) *Logger {

This is backward-compatible since *os.File implements io.Writer.

See PR #176 for context.

`logging.NewFromWriter(w *os.File)` takes a concrete `*os.File` type, but the underlying `log.New()` accepts `io.Writer`. Restricting to `*os.File` prevents using other writers (e.g., `bytes.Buffer` for tests, network connections). **Suggested fix:** Change the parameter type to `io.Writer`: ```go func NewFromWriter(w io.Writer) *Logger { ``` This is backward-compatible since `*os.File` implements `io.Writer`. See PR #176 for context.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/ttheart#177
No description provided.