srs/internal/lb/debug.go
Winlin d8696434cb
Proxy: Refine logger and environment APIs. v7.0.146 (#4670)
This PR refines the next-generation proxy internals and workspace
documentation:

  - Reworks internal/logger to expose clearer slog-style APIs:
      - Replaces Vf/Df/Wf/Ef with Info/Debug/Warn/Error.
      - Adds structured key/value log arguments.
      - Adds version to every log record.
      - Uses standard slog level labels (DEBUG, INFO, WARN, ERROR).
      - Keeps compatibility for existing printf-style messages.
  - Renames proxy configuration abstractions:
      - Environment → ProxyEnvironment.
      - NewEnvironment → NewProxyEnvironment.
- Regenerates/renames the counterfeiter fake to FakeProxyEnvironment.
- Updates all proxy bootstrap, load balancer, protocol, signal, debug,
and utility call sites for the new logger and
    environment APIs.
  - Consolidates proxy codebase navigation:
      - Deletes docs/proxy/proxy-files.md.
- Moves the useful file/module map details into
.openclaw/memory/srs-codebase-map.md.
- Replaces agent instruction symlinks with explicit workspace
instruction files for Claude, Codex, and Kiro.
  - Updates OpenClaw tool notes with Codex commit-prefix guidance.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 07:18:45 -04:00

51 lines
1.4 KiB
Go

// Copyright (c) 2026 Winlin
//
// SPDX-License-Identifier: MIT
package lb
import (
"fmt"
"os"
"time"
"srsx/internal/env"
"srsx/internal/logger"
)
// NewDefaultSRSForDebugging initialize the default SRS media server, for debugging only.
func NewDefaultSRSForDebugging(environment env.ProxyEnvironment) (*SRSServer, error) {
if environment.DefaultBackendEnabled() != "on" {
return nil, nil
}
if environment.DefaultBackendIP() == "" {
return nil, fmt.Errorf("empty default backend ip")
}
if environment.DefaultBackendRTMP() == "" {
return nil, fmt.Errorf("empty default backend rtmp")
}
server := NewSRSServer(func(srs *SRSServer) {
srs.IP = environment.DefaultBackendIP()
srs.RTMP = []string{environment.DefaultBackendRTMP()}
srs.ServerID = fmt.Sprintf("default-%v", logger.GenerateContextID())
srs.ServiceID = logger.GenerateContextID()
srs.PID = fmt.Sprintf("%v", os.Getpid())
srs.UpdatedAt = time.Now()
})
if environment.DefaultBackendHttp() != "" {
server.HTTP = []string{environment.DefaultBackendHttp()}
}
if environment.DefaultBackendAPI() != "" {
server.API = []string{environment.DefaultBackendAPI()}
}
if environment.DefaultBackendRTC() != "" {
server.RTC = []string{environment.DefaultBackendRTC()}
}
if environment.DefaultBackendSRT() != "" {
server.SRT = []string{environment.DefaultBackendSRT()}
}
return server, nil
}