aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Utilities/Log.cs
diff options
context:
space:
mode:
authorSean Dague2007-07-16 15:40:11 +0000
committerSean Dague2007-07-16 15:40:11 +0000
commit2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch)
treee3f80ad51736cf17e856547b1bcf956010927434 /Prebuild/src/Core/Utilities/Log.cs
parent*Trunk compiles now (diff)
downloadopensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip
opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz
opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2
opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz
changed to native line ending encoding
Diffstat (limited to 'Prebuild/src/Core/Utilities/Log.cs')
-rw-r--r--Prebuild/src/Core/Utilities/Log.cs558
1 files changed, 279 insertions, 279 deletions
diff --git a/Prebuild/src/Core/Utilities/Log.cs b/Prebuild/src/Core/Utilities/Log.cs
index da2cc96..2f26557 100644
--- a/Prebuild/src/Core/Utilities/Log.cs
+++ b/Prebuild/src/Core/Utilities/Log.cs
@@ -1,279 +1,279 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) 3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8* Redistributions of source code must retain the above copyright notice, this list of conditions 8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software 13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/ 23*/
24#endregion 24#endregion
25 25
26#region CVS Information 26#region CVS Information
27/* 27/*
28 * $Source$ 28 * $Source$
29 * $Author: jendave $ 29 * $Author: jendave $
30 * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ 30 * $Date: 2006-01-28 01:49:58 +0100 (lö, 28 jan 2006) $
31 * $Revision: 71 $ 31 * $Revision: 71 $
32 */ 32 */
33#endregion 33#endregion
34 34
35using System; 35using System;
36using System.IO; 36using System.IO;
37 37
38namespace Prebuild.Core.Utilities 38namespace Prebuild.Core.Utilities
39{ 39{
40 /// <summary> 40 /// <summary>
41 /// 41 ///
42 /// </summary> 42 /// </summary>
43 public enum LogType 43 public enum LogType
44 { 44 {
45 /// <summary> 45 /// <summary>
46 /// 46 ///
47 /// </summary> 47 /// </summary>
48 None, 48 None,
49 /// <summary> 49 /// <summary>
50 /// 50 ///
51 /// </summary> 51 /// </summary>
52 Info, 52 Info,
53 /// <summary> 53 /// <summary>
54 /// 54 ///
55 /// </summary> 55 /// </summary>
56 Warning, 56 Warning,
57 /// <summary> 57 /// <summary>
58 /// 58 ///
59 /// </summary> 59 /// </summary>
60 Error 60 Error
61 } 61 }
62 62
63 /// <summary> 63 /// <summary>
64 /// 64 ///
65 /// </summary> 65 /// </summary>
66 [Flags] 66 [Flags]
67 public enum LogTargets 67 public enum LogTargets
68 { 68 {
69 /// <summary> 69 /// <summary>
70 /// 70 ///
71 /// </summary> 71 /// </summary>
72 None = 0, 72 None = 0,
73 /// <summary> 73 /// <summary>
74 /// 74 ///
75 /// </summary> 75 /// </summary>
76 Null = 1, 76 Null = 1,
77 /// <summary> 77 /// <summary>
78 /// 78 ///
79 /// </summary> 79 /// </summary>
80 File = 2, 80 File = 2,
81 /// <summary> 81 /// <summary>
82 /// 82 ///
83 /// </summary> 83 /// </summary>
84 Console = 4 84 Console = 4
85 } 85 }
86 86
87 /// <summary> 87 /// <summary>
88 /// Summary description for Log. 88 /// Summary description for Log.
89 /// </summary> 89 /// </summary>
90 public class Log : IDisposable 90 public class Log : IDisposable
91 { 91 {
92 #region Fields 92 #region Fields
93 93
94 private StreamWriter m_Writer; 94 private StreamWriter m_Writer;
95 private LogTargets m_Target = LogTargets.Null; 95 private LogTargets m_Target = LogTargets.Null;
96 bool disposed; 96 bool disposed;
97 97
98 #endregion 98 #endregion
99 99
100 #region Constructors 100 #region Constructors
101 101
102 /// <summary> 102 /// <summary>
103 /// Initializes a new instance of the <see cref="Log"/> class. 103 /// Initializes a new instance of the <see cref="Log"/> class.
104 /// </summary> 104 /// </summary>
105 /// <param name="target">The target.</param> 105 /// <param name="target">The target.</param>
106 /// <param name="fileName">Name of the file.</param> 106 /// <param name="fileName">Name of the file.</param>
107 public Log(LogTargets target, string fileName) 107 public Log(LogTargets target, string fileName)
108 { 108 {
109 m_Target = target; 109 m_Target = target;
110 110
111 if((m_Target & LogTargets.File) != 0) 111 if((m_Target & LogTargets.File) != 0)
112 { 112 {
113 m_Writer = new StreamWriter(fileName, false); 113 m_Writer = new StreamWriter(fileName, false);
114 } 114 }
115 } 115 }
116 116
117 #endregion 117 #endregion
118 118
119 #region Public Methods 119 #region Public Methods
120 120
121 /// <summary> 121 /// <summary>
122 /// Writes this instance. 122 /// Writes this instance.
123 /// </summary> 123 /// </summary>
124 public void Write() 124 public void Write()
125 { 125 {
126 Write(string.Empty); 126 Write(string.Empty);
127 } 127 }
128 128
129 /// <summary> 129 /// <summary>
130 /// Writes the specified MSG. 130 /// Writes the specified MSG.
131 /// </summary> 131 /// </summary>
132 /// <param name="msg">The MSG.</param> 132 /// <param name="msg">The MSG.</param>
133 public void Write(string msg) 133 public void Write(string msg)
134 { 134 {
135 if((m_Target & LogTargets.Null) != 0) 135 if((m_Target & LogTargets.Null) != 0)
136 { 136 {
137 return; 137 return;
138 } 138 }
139 139
140 if((m_Target & LogTargets.Console) != 0) 140 if((m_Target & LogTargets.Console) != 0)
141 { 141 {
142 Console.WriteLine(msg); 142 Console.WriteLine(msg);
143 } 143 }
144 if((m_Target & LogTargets.File) != 0 && m_Writer != null) 144 if((m_Target & LogTargets.File) != 0 && m_Writer != null)
145 { 145 {
146 m_Writer.WriteLine(msg); 146 m_Writer.WriteLine(msg);
147 } 147 }
148 } 148 }
149 149
150 /// <summary> 150 /// <summary>
151 /// Writes the specified format. 151 /// Writes the specified format.
152 /// </summary> 152 /// </summary>
153 /// <param name="format">The format.</param> 153 /// <param name="format">The format.</param>
154 /// <param name="args">The args.</param> 154 /// <param name="args">The args.</param>
155 public void Write(string format, params object[] args) 155 public void Write(string format, params object[] args)
156 { 156 {
157 Write(string.Format(format,args)); 157 Write(string.Format(format,args));
158 } 158 }
159 159
160 /// <summary> 160 /// <summary>
161 /// Writes the specified type. 161 /// Writes the specified type.
162 /// </summary> 162 /// </summary>
163 /// <param name="type">The type.</param> 163 /// <param name="type">The type.</param>
164 /// <param name="format">The format.</param> 164 /// <param name="format">The format.</param>
165 /// <param name="args">The args.</param> 165 /// <param name="args">The args.</param>
166 public void Write(LogType type, string format, params object[] args) 166 public void Write(LogType type, string format, params object[] args)
167 { 167 {
168 if((m_Target & LogTargets.Null) != 0) 168 if((m_Target & LogTargets.Null) != 0)
169 { 169 {
170 return; 170 return;
171 } 171 }
172 172
173 string str = ""; 173 string str = "";
174 switch(type) 174 switch(type)
175 { 175 {
176 case LogType.Info: 176 case LogType.Info:
177 str = "[I] "; 177 str = "[I] ";
178 break; 178 break;
179 case LogType.Warning: 179 case LogType.Warning:
180 str = "[!] "; 180 str = "[!] ";
181 break; 181 break;
182 case LogType.Error: 182 case LogType.Error:
183 str = "[X] "; 183 str = "[X] ";
184 break; 184 break;
185 } 185 }
186 186
187 Write(str + format,args); 187 Write(str + format,args);
188 } 188 }
189 189
190 /// <summary> 190 /// <summary>
191 /// Writes the exception. 191 /// Writes the exception.
192 /// </summary> 192 /// </summary>
193 /// <param name="type">The type.</param> 193 /// <param name="type">The type.</param>
194 /// <param name="ex">The ex.</param> 194 /// <param name="ex">The ex.</param>
195 public void WriteException(LogType type, Exception ex) 195 public void WriteException(LogType type, Exception ex)
196 { 196 {
197 if(ex != null) 197 if(ex != null)
198 { 198 {
199 Write(type, ex.Message); 199 Write(type, ex.Message);
200 //#if DEBUG 200 //#if DEBUG
201 m_Writer.WriteLine("Exception @{0} stack trace [[", ex.TargetSite.Name); 201 m_Writer.WriteLine("Exception @{0} stack trace [[", ex.TargetSite.Name);
202 m_Writer.WriteLine(ex.StackTrace); 202 m_Writer.WriteLine(ex.StackTrace);
203 m_Writer.WriteLine("]]"); 203 m_Writer.WriteLine("]]");
204 //#endif 204 //#endif
205 } 205 }
206 } 206 }
207 207
208 /// <summary> 208 /// <summary>
209 /// Flushes this instance. 209 /// Flushes this instance.
210 /// </summary> 210 /// </summary>
211 public void Flush() 211 public void Flush()
212 { 212 {
213 if(m_Writer != null) 213 if(m_Writer != null)
214 { 214 {
215 m_Writer.Flush(); 215 m_Writer.Flush();
216 } 216 }
217 } 217 }
218 218
219 #endregion 219 #endregion
220 220
221 #region IDisposable Members 221 #region IDisposable Members
222 222
223 /// <summary> 223 /// <summary>
224 /// Performs application-defined tasks associated with freeing, releasing, or 224 /// Performs application-defined tasks associated with freeing, releasing, or
225 /// resetting unmanaged resources. 225 /// resetting unmanaged resources.
226 /// </summary> 226 /// </summary>
227 public void Dispose() 227 public void Dispose()
228 { 228 {
229 Dispose(true); 229 Dispose(true);
230 GC.SuppressFinalize(this); 230 GC.SuppressFinalize(this);
231 } 231 }
232 232
233 /// <summary> 233 /// <summary>
234 /// Dispose objects 234 /// Dispose objects
235 /// </summary> 235 /// </summary>
236 /// <param name="disposing"> 236 /// <param name="disposing">
237 /// If true, it will dispose close the handle 237 /// If true, it will dispose close the handle
238 /// </param> 238 /// </param>
239 /// <remarks> 239 /// <remarks>
240 /// Will dispose managed and unmanaged resources. 240 /// Will dispose managed and unmanaged resources.
241 /// </remarks> 241 /// </remarks>
242 protected virtual void Dispose(bool disposing) 242 protected virtual void Dispose(bool disposing)
243 { 243 {
244 if (!this.disposed) 244 if (!this.disposed)
245 { 245 {
246 if (disposing) 246 if (disposing)
247 { 247 {
248 if (m_Writer != null) 248 if (m_Writer != null)
249 { 249 {
250 m_Writer.Close(); 250 m_Writer.Close();
251 m_Writer = null; 251 m_Writer = null;
252 } 252 }
253 } 253 }
254 } 254 }
255 this.disposed = true; 255 this.disposed = true;
256 } 256 }
257 257
258 /// <summary> 258 /// <summary>
259 /// 259 ///
260 /// </summary> 260 /// </summary>
261 ~Log() 261 ~Log()
262 { 262 {
263 this.Dispose(false); 263 this.Dispose(false);
264 } 264 }
265 265
266 /// <summary> 266 /// <summary>
267 /// Closes and destroys this object 267 /// Closes and destroys this object
268 /// </summary> 268 /// </summary>
269 /// <remarks> 269 /// <remarks>
270 /// Same as Dispose(true) 270 /// Same as Dispose(true)
271 /// </remarks> 271 /// </remarks>
272 public void Close() 272 public void Close()
273 { 273 {
274 Dispose(); 274 Dispose();
275 } 275 }
276 276
277 #endregion 277 #endregion
278 } 278 }
279} 279}