private void WOnLogRotated(object sender, ZipRotationPerformedEventArgs e) { _log?.Trace($"Log rotated: {e.ZipFile}"); LogRotated?.Invoke(this, e); }
private void ZipperOnLogRotated(object sender, ZipRotationPerformedEventArgs e) { LogRotated?.Invoke(this, e); }
private void LogCompress([CanBeNull] string message = "") { if (!string.IsNullOrEmpty(message)) { _log?.Trace(message); } try { lock (_lck) { var d = DateTime.Now; var dDay = $"{d:yyyy-MM-dd}"; var dTime = $"{d:HH-mm-ss}"; if (!string.IsNullOrEmpty(_zipDirectoryOverridePath)) { _zipDirectoryOutputPath = new DirectoryInfo(_zipDirectoryOverridePath); if (!_zipDirectoryOutputPath.Exists) { _zipDirectoryOutputPath.Create(); } } else { _zipDirectoryOutputPath = new DirectoryInfo(_directory.FullName); } var outDir = new DirectoryInfo($"{_zipDirectoryOutputPath.FullName}{Path.DirectorySeparatorChar}{dDay}"); if (!outDir.Exists) { outDir.Create(); } var zipFile = new FileInfo($"{outDir.FullName}{Path.DirectorySeparatorChar}{dDay}.zip"); var zipper = new NewZipper(); zipper.LogRotated += (sender, args) => LogRotated?.Invoke(this, args); var l = new Dictionary <string, FileInfo>(); int c = 0; while (_zipQueue.Count > 0) { c++; FileInfo file = new FileInfo(_zipQueue.Dequeue()); if (file.Exists) { var entryName = $"{dDay}_{dTime}__{file.Name}_{c}.log"; l.Add(entryName, file); } } if (l.Count > 0) { zipper.AddEntries(l, zipFile.FullName, CompressionLevel.BestCompression); //LogRotated?.Invoke(this, new ZipRotationPerformedEventArgs(zipFile.FullName) ); } } } catch (Exception exception) { _log?.Error($"LogCompress exception '{exception.Message}'", exception); // } }
protected virtual void OnLogRotated(ZipRotationPerformedEventArgs e) { LogRotated?.Invoke(this, e); }
private void RollingPoolOnLogRotated(object sender, ZipRotationPerformedEventArgs e) { LogRotated?.Invoke(sender, e); }