Changeset 6423
- Timestamp:
- 06/16/11 10:30:26 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Log.cs
r5445 r6423 43 43 } 44 44 45 [Storable] 46 protected long maxMessageCount; 47 public virtual long MaxMessageCount { 48 get { return maxMessageCount; } 49 } 50 45 51 [StorableConstructor] 46 52 protected Log(bool deserializing) : base(deserializing) { } 47 53 protected Log(Log original, Cloner cloner) 48 54 : base(original, cloner) { 49 messages = new List<string>(original.messages); 55 this.messages = new List<string>(original.messages); 56 this.maxMessageCount = original.maxMessageCount; 50 57 } 51 public Log( )58 public Log(long maxMessageCount = -1) 52 59 : base() { 53 messages = new List<string>(); 60 this.messages = new List<string>(); 61 this.maxMessageCount = maxMessageCount; 54 62 } 55 63 … … 65 73 string s = DateTime.Now.ToString() + "\t" + message; 66 74 messages.Add(s); 75 CapMessages(); 67 76 OnMessageAdded(s); 68 77 } … … 70 79 string s = DateTime.Now.ToString() + "\t" + "Exception occurred:" + Environment.NewLine + ErrorHandling.BuildErrorMessage(ex); 71 80 messages.Add(s); 81 CapMessages(); 72 82 OnMessageAdded(s); 83 } 84 protected virtual void CapMessages() { 85 while (maxMessageCount >= 0 && messages.Count > maxMessageCount) { 86 messages.RemoveAt(0); 87 } 73 88 } 74 89
Note: See TracChangeset
for help on using the changeset viewer.