feat(logging): implement leveled logger with timestamp prefixes #176

Merged
fuzzy merged 2 commits from feature/implement-logging into main 2026-07-06 07:24:11 +00:00
Owner

What

Implement a leveled logger in logging/logger.go wrapping the standard log package:

  • Info() — informational messages with [INFO] prefix and timestamp
  • Warn() — warning messages with [WARN] prefix and timestamp
  • Error() — error messages with [ERROR] prefix and timestamp
  • New() — default constructor writing to os.Stdout
  • NewFromWriter() — configurable writer for testing and custom output

Why

Centralized logging is required by the project conventions. All components (webhook handler, rule matcher, executor) will use this logger for consistent, leveled output.

Testing

  • Unit tests pass — 3 subtests verifying each log level outputs correct prefix and routed message
  • Integration tests pass — N/A
  • Manual testing performed — go test ./... and pre-commit pass
  • New tests added for new functionality — logger_test.go with table-driven tests

Breaking Changes

None.

Notes

  • Uses log.LstdFlags for date/time prefix on every line
  • External test package (package logging_test) for public API testing
  • Location follows Go conventions: top-level logging/ directory

Closes #25
Closes #22
Closes #23
Closes #24

## What Implement a leveled logger in `logging/logger.go` wrapping the standard `log` package: - `Info()` — informational messages with `[INFO]` prefix and timestamp - `Warn()` — warning messages with `[WARN]` prefix and timestamp - `Error()` — error messages with `[ERROR]` prefix and timestamp - `New()` — default constructor writing to `os.Stdout` - `NewFromWriter()` — configurable writer for testing and custom output ## Why Centralized logging is required by the project conventions. All components (webhook handler, rule matcher, executor) will use this logger for consistent, leveled output. ## Testing - [x] Unit tests pass — 3 subtests verifying each log level outputs correct prefix and routed message - [ ] Integration tests pass — N/A - [x] Manual testing performed — `go test ./...` and pre-commit pass - [x] New tests added for new functionality — `logger_test.go` with table-driven tests ## Breaking Changes None. ## Notes - Uses `log.LstdFlags` for date/time prefix on every line - External test package (`package logging_test`) for public API testing - Location follows Go conventions: top-level `logging/` directory Closes #25 Closes #22 Closes #23 Closes #24
Add Logger wrapping standard log package with Info, Warn, Error levels.
Each level prepends [INFO], [WARN], or [ERROR] prefix with timestamp.
Logger writes to os.Stdout by default or any configurable writer.

Closes #22
Closes #23
Closes #24
docs: mark Implement logging infrastructure tasks as complete
All checks were successful
CI / Lint (golangci-lint) (pull_request) Successful in 1m8s
CI / Pre-commit Hooks (pull_request) Successful in 1m59s
CI / Test (pull_request) Successful in 1m18s
CI / Lint (golangci-lint) (push) Successful in 1m17s
CI / Pre-commit Hooks (push) Successful in 2m9s
CI / Test (push) Successful in 1m26s
5414abfd71
Closes #25
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-06 07:22:24 +00:00
the.auditor left a comment

Review

Clean implementation of a leveled logger. Lint, vet, and tests all pass with zero issues.

Design: Logger wraps log.New with separate instances per level. Prefix spacing aligns output nicely:

[INFO]  message
[WARN]  message
[ERROR] message

Uses log.LstdFlags for timestamp prefixes. New() writes to os.Stdout, NewFromWriter() allows writer injection.

Tests: Table-driven, covers all three levels, verifies both prefix and formatted message via pipe capture. External test package — proper for public API testing.

Non-blocking

  1. logger.go:26NewFromWriter accepts *os.File but should accept io.Writer for flexibility. Filed as #177.

No blocking issues.

APPROVED

## Review Clean implementation of a leveled logger. Lint, vet, and tests all pass with zero issues. **Design**: Logger wraps `log.New` with separate instances per level. Prefix spacing aligns output nicely: ``` [INFO] message [WARN] message [ERROR] message ``` Uses `log.LstdFlags` for timestamp prefixes. `New()` writes to `os.Stdout`, `NewFromWriter()` allows writer injection. **Tests**: Table-driven, covers all three levels, verifies both prefix and formatted message via pipe capture. External test package — proper for public API testing. ## Non-blocking 1. `logger.go:26` — `NewFromWriter` accepts `*os.File` but should accept `io.Writer` for flexibility. Filed as #177. **No blocking issues.** **APPROVED**
fuzzy merged commit 5414abfd71 into main 2026-07-06 07:24:11 +00:00
fuzzy deleted branch feature/implement-logging 2026-07-06 07:24:11 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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!176
No description provided.