public Result <IEnumerable <string> > GetLogs(string service, DateTime @from, DateTime to) { if (!registeredServices.TryGetValue(service.ToLower(), out var serviceFolder)) { return($"Service \"{service}\" not found"); } var filenames = GetMonthsBetweenPeriod(from, to) .Select(d => Path.Combine(serviceFolder, FileLog.GetFileName(d))) .ToArray(); if (filenames.All(f => !File.Exists(f))) { return($"No logs for this period"); } var logs = filenames .Where(File.Exists) .SelectMany(File.ReadLines) .SkipWhile(s => LogFormatter.GetLogTime(s) < from) .TakeWhile(s => LogFormatter.GetLogTime(s) <= to); return(Result.Ok(logs)); }