/// <summary> /// Initializes a new instance of the <see cref="LogArchiveTracer"/> class. /// </summary> /// <param name="log">The log file this tracer traces to.</param> public LogArchiveTracer(PageableLog log) { this.log = log; this.logZipArchive = ZipFile.Open(this.log.ArchiveFileName, ZipArchiveMode.Update); ZipArchiveEntry logFileEntry = this.logZipArchive.Entries.FirstOrDefault(entry => entry.Name == this.log.Name) ?? this.logZipArchive.CreateEntry(this.log.Name, CompressionLevel.Optimal); this.logFileStream = logFileEntry.Open(); this.tracerStreamWriter = new StreamWriter(this.logFileStream); }
/// <summary> /// Returns the requested log from the archive. If the log does not exist, a new empty log will be created and returned. /// </summary> /// <param name="logName">The name of the requested log.</param> /// <param name="initialPageSize">The log's initial page size</param> /// <returns>A <see cref="Task"/> running the asynchronous operation, returning the requested log.</returns> public async Task <IPageableLog> GetLogAsync(string logName, int initialPageSize) { IPageableLog log = await PageableLog.LoadLogFileAsync(this.archiveFileName, logName, initialPageSize); if (!this.LogNames.Contains(log.Name)) { this.LogNames.Add(log.Name); } return(log); }