mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 00:54:23 +00:00
Remove redundant instance prefix from logger
This commit is contained in:
@@ -44,7 +44,7 @@ type Process struct {
|
|||||||
Created int64 `json:"created,omitempty"` // Unix timestamp when the instance was created
|
Created int64 `json:"created,omitempty"` // Unix timestamp when the instance was created
|
||||||
|
|
||||||
// Logging file
|
// Logging file
|
||||||
logger *InstanceLogger `json:"-"`
|
logger *Logger `json:"-"`
|
||||||
|
|
||||||
// internal
|
// internal
|
||||||
cmd *exec.Cmd `json:"-"` // Command to run the instance
|
cmd *exec.Cmd `json:"-"` // Command to run the instance
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type InstanceLogger struct {
|
type Logger struct {
|
||||||
name string
|
name string
|
||||||
logDir string
|
logDir string
|
||||||
logFile *os.File
|
logFile *os.File
|
||||||
@@ -18,15 +18,15 @@ type InstanceLogger struct {
|
|||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewInstanceLogger(name string, logDir string) *InstanceLogger {
|
func NewInstanceLogger(name string, logDir string) *Logger {
|
||||||
return &InstanceLogger{
|
return &Logger{
|
||||||
name: name,
|
name: name,
|
||||||
logDir: logDir,
|
logDir: logDir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates and opens the log files for stdout and stderr
|
// Create creates and opens the log files for stdout and stderr
|
||||||
func (i *InstanceLogger) Create() error {
|
func (i *Logger) Create() error {
|
||||||
i.mu.Lock()
|
i.mu.Lock()
|
||||||
defer i.mu.Unlock()
|
defer i.mu.Unlock()
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ func (i *InstanceLogger) Create() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetLogs retrieves the last n lines of logs from the instance
|
// 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()
|
i.mu.RLock()
|
||||||
defer i.mu.RUnlock()
|
defer i.mu.RUnlock()
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ func (i *InstanceLogger) GetLogs(num_lines int) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// closeLogFile closes the log files
|
// closeLogFile closes the log files
|
||||||
func (i *InstanceLogger) Close() {
|
func (i *Logger) Close() {
|
||||||
i.mu.Lock()
|
i.mu.Lock()
|
||||||
defer i.mu.Unlock()
|
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
|
// 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()
|
defer reader.Close()
|
||||||
|
|
||||||
scanner := bufio.NewScanner(reader)
|
scanner := bufio.NewScanner(reader)
|
||||||
|
|||||||
Reference in New Issue
Block a user