Skip to content

Move logger implementation to toolhive-core#3616

Open
niveshdandyan wants to merge 1 commit intostacklok:mainfrom
niveshdandyan:feat/move-logger-to-core
Open

Move logger implementation to toolhive-core#3616
niveshdandyan wants to merge 1 commit intostacklok:mainfrom
niveshdandyan:feat/move-logger-to-core

Conversation

@niveshdandyan
Copy link

Summary

Moves the shared logger package implementation to toolhive-core for better code organization and reuse across ToolHive projects. Both ToolHive Runtime and Registry rely on structured logging and this change enables convergence on a common logging format.

Fixes #3614

Changes

  • Refactored logger package to delegate to github.com/stacklok/toolhive-core/logger
  • Introduced DebugProvider interface in toolhive-core for configurable debug mode
  • Created viperDebugProvider in toolhive for viper-based debug configuration
  • Maintained all existing function signatures for backward compatibility
  • Updated tests to work with the new implementation

Architecture

The logger package now follows a thin-wrapper pattern:

toolhive/pkg/logger          toolhive-core/logger
┌─────────────────────┐      ┌──────────────────────┐
│ viperDebugProvider  │─────>│ DebugProvider iface  │
│ Initialize()        │─────>│ InitializeWithDebug()│
│ Debug/Info/Warn/... │─────>│ Debug/Info/Warn/...  │
└─────────────────────┘      └──────────────────────┘

This design:

  1. Keeps viper dependency in toolhive (not in toolhive-core)
  2. Allows toolhive-core to remain lean with minimal dependencies
  3. Enables other projects to use the logger with their own debug providers
  4. Maintains full backward compatibility with existing code

Testing

  • All imports resolve correctly
  • go build ./... succeeds
  • go test ./... passes (if applicable)

Note: This PR depends on the logger package being added to toolhive-core.
A corresponding PR has been prepared at: https://github.com/niveshdandyan/toolhive-core/tree/feat/add-logger-package

AI Transparency

This PR was created with the assistance of AI (Claude by Anthropic) for code generation and review.

Refactors the logger package to use the shared logger from toolhive-core,
while maintaining backward compatibility with the existing API.

Changes:
- Logger implementation now delegates to github.com/stacklok/toolhive-core/logger
- Introduces viperDebugProvider for viper integration with the core logger
- Maintains all existing function signatures for backward compatibility
- Updates tests to work with the new implementation

The logger package in toolhive now serves as a thin wrapper that:
1. Re-exports all logging functions from toolhive-core
2. Provides viper-based debug configuration via DebugProvider interface
3. Preserves the Initialize() API that uses viper for debug flag

This enables logger code reuse across ToolHive Runtime and Registry
while keeping project-specific configuration (viper) in each project.

Fixes stacklok#3614

Co-Authored-By: Claude (claude-opus-4-5) <noreply@anthropic.com>
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.

Move shared logger package to toolhive-core

1 participant