Exemple #1
0
        public void Write(LogItem logItem)
        {
            string messageString = logItem.ToString();
            Trace.WriteLine(messageString);
            Console.WriteLine(messageString);

            try {
                lock (_syncRoot) {
                    CreateFileWithHeader();
                    AddLineToLogFile(messageString);
                }
            }
            catch(Exception ex) {
                System.Diagnostics.Trace.TraceError("Unable to write to log file. Ignoring it. Error:.\r\n{0}",ex.ToString());
            }
        }
        private void WriteToLog(object sender, CompressionResult e)
        {
            if (!_cmdLineOptions.SuppressCsvReport) {
                ThreadPool.QueueUserWorkItem((o) => {
                    _store.Save(e.OriginalFileName);

                    if (e == null /*|| e.ResultFileSize == 0*/) {
                        return;
                    }
                    var logItem = new LogItem { FileName = BuildRelativeFilePath(e.OriginalFileName), OriginalSizeBytes = e.OriginalFileSize, NewSizeBytes = e.ResultFileSize };
                    _logger.Write(logItem);
                });
            }
        }
Exemple #3
0
 private void WriteToLog(string modifiedFilePath, long originalSizeBytes, long newSizeBytes)
 {
     if (!_cmdLineOptions.SuppressCsvReport) {
         ThreadPool.QueueUserWorkItem((o) => {
             var logItem = new LogItem {
                 FileName = BuildRelativeFilePath(modifiedFilePath),
                 OriginalSizeBytes = originalSizeBytes,
                 NewSizeBytes = newSizeBytes
             };
             _logger.Write(logItem);
         });
     }
 }