Explorar o código

Merge pull request #235 from yeungalan/claude/eloquent-cannon-oZi0P

Refactor AGI logger initialization and remove duplicate import
Alan Yeung hai 2 semanas
pai
achega
0d1aa889b0
Modificáronse 2 ficheiros con 4 adicións e 5 borrados
  1. 0 1
      src/mod/agi/agi.go
  2. 4 4
      src/mod/agi/agi.system.go

+ 0 - 1
src/mod/agi/agi.go

@@ -21,7 +21,6 @@ import (
 	"imuslab.com/arozos/mod/filesystem/arozfs"
 	"imuslab.com/arozos/mod/info/logger"
 	metadata "imuslab.com/arozos/mod/filesystem/metadata"
-	"imuslab.com/arozos/mod/info/logger"
 	"imuslab.com/arozos/mod/iot"
 	"imuslab.com/arozos/mod/share"
 	"imuslab.com/arozos/mod/time/nightly"

+ 4 - 4
src/mod/agi/agi.system.go

@@ -42,10 +42,10 @@ func (g *Gateway) injectStandardLibs(vm *otto.Otto, scriptFile string, scriptSco
 	// Override otto's built-in console.log (which maps to fmt.Println) so that
 	// script output goes through the structured logger and carries the execID.
 	// Use the system-wide logger (with file output) when available; fall back to
-	// agiLogger (stdout only) if the Gateway was created without one.
-	scriptLogger := agiLogger
-	if g.Option.Logger != nil {
-		scriptLogger = g.Option.Logger
+	// a tmp stdout-only logger if the Gateway was created without one.
+	scriptLogger := g.Option.Logger
+	if scriptLogger == nil {
+		scriptLogger, _ = logger.NewTmpLogger()
 	}
 	vm.Set("_agi_console_log", func(call otto.FunctionCall) otto.Value {
 		parts := make([]string, 0, len(call.ArgumentList))