Skip to content

M1.6: Set up slog-based structured logging #6

Description

@bjcorder

Labels: type:feature, area:cli, priority:high,
status:blocked, milestone:M1, phase:1

Summary

Configure log/slog (Go 1.21+ stdlib) as the project-wide logger, with
JSON output by default and human-readable when --log-format=text.

Acceptance criteria

  • internal/logging/logging.go exposes Setup(format, level string) *slog.Logger
  • JSON handler is the default; text handler when format=text
  • Level is configurable via the level string
  • The configured logger is set as the default via
    slog.SetDefault()
  • Logger is wired into the cobra root command's PersistentPreRunE
  • Sample logs are emitted by stub subcommands to demonstrate the
    setup works

Implementation notes

Use only log/slog from the standard library — no third-party logging
libraries. Format the JSON to include time, level, msg, and any
structured fields.

Dependencies

Depends on: #5

Verification

./forkguard --log-format=text ingest 2>&1 | grep "not implemented"
./forkguard --log-format=json ingest 2>&1 | jq .level

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliCLI commands, argument parsing, output formattinggood-first-issueApproachable for new contributorspriority:highImportant for the current milestonetype:featureNew functionality

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions