Add optional "log_file" configuration option.
This commit is contained in:
@@ -17,6 +17,9 @@ type Config struct {
|
||||
// DataDir is the base directory for all database files.
|
||||
DataDir string `json:"data_dir"`
|
||||
|
||||
// LogFile is the optional path to a file where logs will be written.
|
||||
LogFile string `json:"log_file"`
|
||||
|
||||
// HotRetentionHours is how many hours of raw ticks to keep in the hot DB.
|
||||
HotRetentionHours int `json:"hot_retention_hours"`
|
||||
|
||||
@@ -42,6 +45,7 @@ func DefaultConfig() Config {
|
||||
WebSocketURL: "wss://stream.bybit.com/v5/public/linear",
|
||||
Symbol: "BTCUSDT",
|
||||
DataDir: "data",
|
||||
LogFile: "engine.log",
|
||||
HotRetentionHours: 12,
|
||||
FeatureRetentionDays: 30,
|
||||
WriterFlushIntervalMs: 500,
|
||||
@@ -52,14 +56,12 @@ func DefaultConfig() Config {
|
||||
}
|
||||
|
||||
// LoadConfig reads a JSON config file and merges with defaults.
|
||||
// If the file does not exist, defaults are returned and a config file is written.
|
||||
func LoadConfig(path string) (Config, error) {
|
||||
cfg := DefaultConfig()
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// Write default config for user reference
|
||||
if writeErr := writeDefaultConfig(path, cfg); writeErr != nil {
|
||||
return cfg, fmt.Errorf("failed to write default config: %w", writeErr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user