Skip to content

refactor: optimize logging and debug configuration#11

Merged
iohub merged 1 commit into
mainfrom
feat-0428
Apr 28, 2026
Merged

refactor: optimize logging and debug configuration#11
iohub merged 1 commit into
mainfrom
feat-0428

Conversation

@iohub
Copy link
Copy Markdown
Owner

@iohub iohub commented Apr 28, 2026

  • upgrade Go version from 1.23.8 to 1.24
  • add debugging dependencies for development (delve, cobra, etc.)
  • disable codebase initialization until binary embedding is ready
  • reduce logger level from debug to error for production
  • remove verbose error logging utilities from error_utils
  • simplify task completion output with structured logging

These changes focus on reducing noise in production while adding debugging capabilities for development environment.

Summary by Sourcery

Streamline runtime logging while preparing the project for updated Go tooling and local debugging support.

Enhancements:

  • Remove verbose contextual error logging and execution helpers to reduce noisy stack traces in production logs.
  • Silence the background codebase initialization workflow until the embedded binary implementation is ready.
  • Adjust task start and completion output to rely on structured slog logging instead of direct console prints, and lower the default log level to error for normal runs.

Build:

  • Upgrade the module Go version to 1.24 and refresh indirect dependencies, including adding debugger- and CLI-related libraries for development tooling.

- upgrade Go version from 1.23.8 to 1.24
- add debugging dependencies for development (delve, cobra, etc.)
- disable codebase initialization until binary embedding is ready
- reduce logger level from debug to error for production
- remove verbose error logging utilities from error_utils
- simplify task completion output with structured logging

These changes focus on reducing noise in production while adding
debugging capabilities for development environment.
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 28, 2026

Reviewer's Guide

Refactors logging and task execution behavior to reduce noisy console output in production, disables background codebase initialization until binary embedding is available, updates Go/tooling versions, and adds development-time debugging dependencies.

Class diagram for updated error_utils module

classDiagram
    class ErrorWithContext {
        +time Time
        +message string
        +context string
        +err error
        +callStack []StackFrame
    }

    class StackFrame {
        +Function string
        +File string
        +Line int
        +Time Time
    }

    class ErrorUtilsBefore {
        +NewErrorWithContext(ctx context.Context, err error, message string) *ErrorWithContext
        +WrapError(ctx context.Context, err error, message string) error
        +LogErrorWithContext(ctx context.Context, err error, message string) void
        +ExecuteWithContext(ctx context.Context, fn func_context_error, operation string) error
        +ExecuteWithContextAndResult_T(ctx context.Context, fn func_context_T_error, operation string) (T, error)
    }

    class ErrorUtilsAfter {
        +NewErrorWithContext(ctx context.Context, err error, message string) *ErrorWithContext
        +WrapError(ctx context.Context, err error, message string) error
    }

    ErrorWithContext "1" *-- "many" StackFrame
    ErrorUtilsBefore ..> ErrorWithContext
    ErrorUtilsAfter ..> ErrorWithContext
Loading

File-Level Changes

Change Details Files
Remove verbose contextual error logging helpers in favor of simpler error wrapping.
  • Delete LogErrorWithContext and its structured stack-printing logic
  • Remove printBacktrace helper that printed human-readable backtraces
  • Remove ExecuteWithContext and ExecuteWithContextAndResult utility wrappers that auto-logged and wrapped errors while executing callbacks
internal/util/error_utils.go
Upgrade Go version and introduce debugging-related indirect dependencies.
  • Bump go directive from 1.23.8 to 1.24
  • Align toolchain to go1.24.7
  • Add Delve, Cobra, and related CLI/debugging libraries as indirect dependencies
  • Update versions of some existing indirect dependencies (e.g., go.starlark.net, golang.org/x/arch) and add telemetry/exp libraries
go.mod
go.sum
Temporarily disable asynchronous codebase initialization during task execution.
  • Comment out the goroutine that POSTs codebase_init requests with project_dir payload
  • Leave a TODO comment indicating it should be re-enabled once the codebase binary is embedded
internal/http/task_executor.go
Tighten production logging level and move task completion output to structured logging.
  • Change default slog handler level from debug to error in init
  • Replace fmt.Printf-based task completion messages with slog.Info/slog.Error calls using the task result/error
  • Remove a noisy fmt.Printf task-start banner in WebSocket handler
main.go
internal/http/websocket.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@iohub iohub merged commit cc8e828 into main Apr 28, 2026
1 check passed
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The block commenting around the background codebase initialization in ExecuteTask uses /** ... */ wrapped around active code and mismatched * lines, which will not compile in Go; replace this with a proper /* ... */ block that cleanly encloses the go func body or gate it with a feature flag instead of commenting out.
  • The global logger level was changed from slog.LevelDebug to slog.LevelError in init(); consider making the log level configurable (e.g., via an environment variable or CLI flag) so development and staging environments can still emit debug/info logs without code changes.
  • The slog.Info/slog.Error calls that replaced fmt.Printf in main.go use the result/error as a bare second argument, which slog interprets as a key without a value; use structured fields instead (e.g., slog.Info("Task completed successfully", "result", finalTask.Result)) and avoid embedding newlines in the message string.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The block commenting around the background codebase initialization in `ExecuteTask` uses `/** ... */` wrapped around active code and mismatched `*` lines, which will not compile in Go; replace this with a proper `/* ... */` block that cleanly encloses the `go func` body or gate it with a feature flag instead of commenting out.
- The global logger level was changed from `slog.LevelDebug` to `slog.LevelError` in `init()`; consider making the log level configurable (e.g., via an environment variable or CLI flag) so development and staging environments can still emit debug/info logs without code changes.
- The `slog.Info`/`slog.Error` calls that replaced `fmt.Printf` in `main.go` use the result/error as a bare second argument, which `slog` interprets as a key without a value; use structured fields instead (e.g., `slog.Info("Task completed successfully", "result", finalTask.Result)`) and avoid embedding newlines in the message string.

## Individual Comments

### Comment 1
<location path="main.go" line_range="26" />
<code_context>
 	// Initialize structured logger with text handler
 	opts := &slog.HandlerOptions{
-		Level: slog.LevelDebug,
+		Level: slog.LevelError,
 	}
 	logger := slog.New(slog.NewTextHandler(os.Stdout, opts))
</code_context>
<issue_to_address>
**question (bug_risk):** The global log level of Error means the success `slog.Info` message will never be emitted.

With `Level: slog.LevelError`, both `slog.Info` and `slog.Debug` are dropped, so the later task-completion `slog.Info` will never be shown while failures logged with `slog.Error` will. If you want users to see successful completion, either lower the log level (e.g., `LevelInfo`), log success with a higher-severity level, or separate user-facing output from structured logs.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread main.go
// Initialize structured logger with text handler
opts := &slog.HandlerOptions{
Level: slog.LevelDebug,
Level: slog.LevelError,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (bug_risk): The global log level of Error means the success slog.Info message will never be emitted.

With Level: slog.LevelError, both slog.Info and slog.Debug are dropped, so the later task-completion slog.Info will never be shown while failures logged with slog.Error will. If you want users to see successful completion, either lower the log level (e.g., LevelInfo), log success with a higher-severity level, or separate user-facing output from structured logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant