Ignore:
Timestamp:
2/9/2010 7:23:22 AM (4 years ago)
Author:
lowjoel
Message:

Redesigned the Logger paradigm -- instead of a dealing with a logger object to do any form of logging, we have a static Logger class which code can log to, and define log targets to receive those logs. Also included is a LogSession? class which sets the log target for the current thread or for a few threads. Addresses #320: Logging improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/CodeReview/Eraser.Manager/Task.cs

    r1767 r1777  
    4747            Targets = (ErasureTargetsCollection)info.GetValue("Targets", typeof(ErasureTargetsCollection)); 
    4848            Targets.Owner = this; 
    49             Log = (Logger)info.GetValue("Log", typeof(Logger)); 
     49            Log = (List<LogSink>)info.GetValue("Log", typeof(List<LogSink>)); 
    5050            Canceled = false; 
    5151 
     
    8383            Schedule = Schedule.RunNow; 
    8484            Canceled = false; 
    85             Log = new Logger(); 
     85            Log = new List<LogSink>(); 
    8686        } 
    8787 
     
    198198        /// The log entries which this task has accumulated. 
    199199        /// </summary> 
    200         public Logger Log { get; private set; } 
     200        public List<LogSink> Log { get; private set; } 
    201201 
    202202        /// <summary> 
     
    481481                //The system cannot read the file, assume no ADSes for lack of 
    482482                //more information. 
    483                 Task.Log.LastSessionEntries.Add(new LogEntry(e.Message, LogLevel.Error)); 
     483                Logger.Log(e.Message, LogLevel.Error); 
    484484            } 
    485485        } 
     
    743743                catch (UnauthorizedAccessException e) 
    744744                { 
    745                     Task.Log.LastSessionEntries.Add(new LogEntry(S._("Could not erase files and " + 
    746                         "subfolders in {0} because {1}", info.FullName, e.Message), LogLevel.Error)); 
     745                    Logger.Log(S._("Could not erase files and subfolders in {0} because {1}", 
     746                        info.FullName, e.Message), LogLevel.Error); 
    747747                } 
    748748            } 
     
    840840            catch (UnauthorizedAccessException e) 
    841841            { 
    842                 Task.Log.LastSessionEntries.Add(new LogEntry(e.Message, LogLevel.Error)); 
     842                Logger.Log(e.Message, LogLevel.Error); 
    843843            } 
    844844        } 
Note: See TracChangeset for help on using the changeset viewer.