From 02909c51535141f2045f5240a5a7393ea7290356 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Tue, 14 Oct 2025 19:46:43 +0200 Subject: [PATCH] Remove redundant instance prefix from logger --- pkg/instance/instance.go | 2 +- pkg/instance/logger.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index e555cae..6ab771b 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -44,7 +44,7 @@ type Process struct { Created int64 `json:"created,omitempty"` // Unix timestamp when the instance was created // Logging file - logger *InstanceLogger `json:"-"` + logger *Logger `json:"-"` // internal cmd *exec.Cmd `json:"-"` // Command to run the instance diff --git a/pkg/instance/logger.go b/pkg/instance/logger.go index 5c993df..10db0fb 100644 --- a/pkg/instance/logger.go +++ b/pkg/instance/logger.go @@ -10,7 +10,7 @@ import ( "time" ) -type InstanceLogger struct { +type Logger struct { name string logDir string logFile *os.File @@ -18,15 +18,15 @@ type InstanceLogger struct { mu sync.RWMutex } -func NewInstanceLogger(name string, logDir string) *InstanceLogger { - return &InstanceLogger{ +func NewInstanceLogger(name string, logDir string) *Logger { + return &Logger{ name: name, logDir: logDir, } } // Create creates and opens the log files for stdout and stderr -func (i *InstanceLogger) Create() error { +func (i *Logger) Create() error { i.mu.Lock() defer i.mu.Unlock() @@ -57,7 +57,7 @@ func (i *InstanceLogger) Create() error { } // GetLogs retrieves the last n lines of logs from the instance -func (i *InstanceLogger) GetLogs(num_lines int) (string, error) { +func (i *Logger) GetLogs(num_lines int) (string, error) { i.mu.RLock() defer i.mu.RUnlock() @@ -98,7 +98,7 @@ func (i *InstanceLogger) GetLogs(num_lines int) (string, error) { } // closeLogFile closes the log files -func (i *InstanceLogger) Close() { +func (i *Logger) Close() { i.mu.Lock() defer i.mu.Unlock() @@ -111,7 +111,7 @@ func (i *InstanceLogger) Close() { } // readOutput reads from the given reader and writes lines to the log file -func (i *InstanceLogger) readOutput(reader io.ReadCloser) { +func (i *Logger) readOutput(reader io.ReadCloser) { defer reader.Close() scanner := bufio.NewScanner(reader)