Move LogRotationConfig to logger package

This commit is contained in:
2025-12-13 12:34:29 +01:00
parent 0b3d654945
commit 406a711682
3 changed files with 12 additions and 12 deletions

View File

@@ -88,13 +88,6 @@ type DatabaseConfig struct {
ConnMaxLifetime time.Duration `yaml:"connection_max_lifetime" json:"connection_max_lifetime" swaggertype:"string" example:"1h"` ConnMaxLifetime time.Duration `yaml:"connection_max_lifetime" json:"connection_max_lifetime" swaggertype:"string" example:"1h"`
} }
// LogRotationConfig contains log rotation settings for instances
type LogRotationConfig struct {
Enabled bool `yaml:"enabled" default:"true"`
MaxSizeMB int `yaml:"max_size_mb" default:"100"` // MB
Compress bool `yaml:"compress" default:"false"`
}
// InstancesConfig contains instance management configuration // InstancesConfig contains instance management configuration
type InstancesConfig struct { type InstancesConfig struct {
// Port range for instances (e.g., 8000,9000) // Port range for instances (e.g., 8000,9000)

View File

@@ -3,10 +3,11 @@ package instance
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"llamactl/pkg/config"
"log" "log"
"net/http" "net/http"
"time" "time"
"llamactl/pkg/config"
) )
// Instance represents a running instance of llama server // Instance represents a running instance of llama server
@@ -68,7 +69,7 @@ func New(name string, globalConfig *config.AppConfig, opts *Options, onStatusCha
// Only create logger, proxy, and process for local instances // Only create logger, proxy, and process for local instances
if !instance.IsRemote() { if !instance.IsRemote() {
logRotationConfig := &config.LogRotationConfig{ logRotationConfig := &LogRotationConfig{
Enabled: globalInstanceSettings.LogRotationEnabled, Enabled: globalInstanceSettings.LogRotationEnabled,
MaxSizeMB: globalInstanceSettings.LogRotationMaxSizeMB, MaxSizeMB: globalInstanceSettings.LogRotationMaxSizeMB,
Compress: globalInstanceSettings.LogRotationCompress, Compress: globalInstanceSettings.LogRotationCompress,

View File

@@ -10,19 +10,25 @@ import (
"time" "time"
timber "github.com/DeRuina/timberjack" timber "github.com/DeRuina/timberjack"
"llamactl/pkg/config"
) )
// LogRotationConfig contains log rotation settings for instances
type LogRotationConfig struct {
Enabled bool `yaml:"enabled" default:"true"`
MaxSizeMB int `yaml:"max_size_mb" default:"100"` // MB
Compress bool `yaml:"compress" default:"false"`
}
type logger struct { type logger struct {
name string name string
logDir string logDir string
logFile *timber.Logger logFile *timber.Logger
logFilePath string logFilePath string
mu sync.RWMutex mu sync.RWMutex
cfg *config.LogRotationConfig cfg *LogRotationConfig
} }
func newLogger(name, logDir string, cfg *config.LogRotationConfig) *logger { func newLogger(name, logDir string, cfg *LogRotationConfig) *logger {
return &logger{ return &logger{
name: name, name: name,
logDir: logDir, logDir: logDir,