package archive import ( "fmt" "time" ) const ( SERVER_VERSION = "archive/3.0" ) type ArchiveServer struct { timezone *time.Location cfg *Config startup time.Time } func NewArchiveServer(cfg *Config) (*ArchiveServer, error) { tz, err := time.LoadLocation(cfg.Timezone) if err != nil { return nil, err } if cfg.LinesPerPage <= 0 { return nil, fmt.Errorf("Invalid %d lines per page", cfg.LinesPerPage) } if len(cfg.Logs) == 0 { return nil, fmt.Errorf("No log sources configured") } for _, ls := range cfg.Logs { if len(ls.FileLocation) == 0 { return nil, fmt.Errorf(`No file locations for log source "%s"`, ls.Description) } } return &ArchiveServer{ timezone: tz, cfg: cfg, startup: time.Now(), }, nil }