mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-06 17:34:58 +01:00
wip: logging improvements
This commit is contained in:
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/opencode-ai/opencode/internal/logging"
|
||||
"github.com/opencode-ai/opencode/internal/pubsub"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
// Manager handles session management, tracking the currently active session.
|
||||
@@ -41,7 +41,7 @@ func InitManager(service Service) {
|
||||
// SetCurrentSession changes the active session to the one with the specified ID.
|
||||
func SetCurrentSession(sessionID string) {
|
||||
if globalManager == nil {
|
||||
logging.Warn("Session manager not initialized")
|
||||
slog.Warn("Session manager not initialized")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -49,18 +49,17 @@ func SetCurrentSession(sessionID string) {
|
||||
defer globalManager.mu.Unlock()
|
||||
|
||||
globalManager.currentSessionID = sessionID
|
||||
logging.Debug("Current session changed", "sessionID", sessionID)
|
||||
slog.Debug("Current session changed", "sessionID", sessionID)
|
||||
}
|
||||
|
||||
// CurrentSessionID returns the ID of the currently active session.
|
||||
func CurrentSessionID() string {
|
||||
if globalManager == nil {
|
||||
logging.Warn("Session manager not initialized")
|
||||
return ""
|
||||
}
|
||||
|
||||
globalManager.mu.RLock()
|
||||
defer globalManager.mu.RUnlock()
|
||||
// globalManager.mu.RLock()
|
||||
// defer globalManager.mu.RUnlock()
|
||||
|
||||
return globalManager.currentSessionID
|
||||
}
|
||||
@@ -69,7 +68,6 @@ func CurrentSessionID() string {
|
||||
// If no session is set or the session cannot be found, it returns nil.
|
||||
func CurrentSession() *Session {
|
||||
if globalManager == nil {
|
||||
logging.Warn("Session manager not initialized")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -80,9 +78,8 @@ func CurrentSession() *Session {
|
||||
|
||||
session, err := globalManager.service.Get(context.Background(), sessionID)
|
||||
if err != nil {
|
||||
logging.Warn("Failed to get current session", "err", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
return &session
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user