aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Utilities/Log.cs
diff options
context:
space:
mode:
authorBlueWall2010-08-31 17:02:36 -0400
committerJustin Clark-Casey (justincc)2010-09-04 02:12:21 +0100
commit1e44ec84bd90ec9078027d1d9d78e83c7d305f2a (patch)
treee34db5ced4bc7bf59b98ff9fb72271dda0f25a33 /Prebuild/src/Core/Utilities/Log.cs
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-1e44ec84bd90ec9078027d1d9d78e83c7d305f2a.zip
opensim-SC-1e44ec84bd90ec9078027d1d9d78e83c7d305f2a.tar.gz
opensim-SC-1e44ec84bd90ec9078027d1d9d78e83c7d305f2a.tar.bz2
opensim-SC-1e44ec84bd90ec9078027d1d9d78e83c7d305f2a.tar.xz
Build system upgrade:
Upgrading Prebuild.exe to correctly construct build solutions for crossplatform tools such as xbuild, monodevelop and nant. NOTE: Module prebuild files will need modification to work, as the prebuild must correctly define the reference path for all assemblies shipped in the OpenSimulator ./bin directory. These include assemblies such as XMLRPC.dll, OpenMetaverse.dll, Nini.dll, etc. . The entries should follow the form: <Reference name="Nini" path="../../../bin/"/> See the distributed prebuild.xml for further examples. Crossplatform tools: xbuild and monodevelop use the vs2008 OpenSim.sln and the .csproj files in each namespace. Changes to the Prebuild.exe are against svn 322 and are included in a patch attached to the mantis. And the dnpb source are available@ svn co https://dnpb.svn.sourceforge.net/svnroot/dnpb dnpb The patches are pending application by the dnpb team. After which, the un-modified upstream Prebuild.exe will work as expected.
Diffstat (limited to 'Prebuild/src/Core/Utilities/Log.cs')
-rw-r--r--Prebuild/src/Core/Utilities/Log.cs270
1 files changed, 0 insertions, 270 deletions
diff --git a/Prebuild/src/Core/Utilities/Log.cs b/Prebuild/src/Core/Utilities/Log.cs
deleted file mode 100644
index 548e987..0000000
--- a/Prebuild/src/Core/Utilities/Log.cs
+++ /dev/null
@@ -1,270 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
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
12 distribution.
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.
15
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
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
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
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System;
27using System.IO;
28
29namespace Prebuild.Core.Utilities
30{
31 /// <summary>
32 ///
33 /// </summary>
34 public enum LogType
35 {
36 /// <summary>
37 ///
38 /// </summary>
39 None,
40 /// <summary>
41 ///
42 /// </summary>
43 Info,
44 /// <summary>
45 ///
46 /// </summary>
47 Warning,
48 /// <summary>
49 ///
50 /// </summary>
51 Error
52 }
53
54 /// <summary>
55 ///
56 /// </summary>
57 [Flags]
58 public enum LogTargets
59 {
60 /// <summary>
61 ///
62 /// </summary>
63 None = 0,
64 /// <summary>
65 ///
66 /// </summary>
67 Null = 1,
68 /// <summary>
69 ///
70 /// </summary>
71 File = 2,
72 /// <summary>
73 ///
74 /// </summary>
75 Console = 4
76 }
77
78 /// <summary>
79 /// Summary description for Log.
80 /// </summary>
81 public class Log : IDisposable
82 {
83 #region Fields
84
85 private StreamWriter m_Writer;
86 private LogTargets m_Target = LogTargets.Null;
87 bool disposed;
88
89 #endregion
90
91 #region Constructors
92
93 /// <summary>
94 /// Initializes a new instance of the <see cref="Log"/> class.
95 /// </summary>
96 /// <param name="target">The target.</param>
97 /// <param name="fileName">Name of the file.</param>
98 public Log(LogTargets target, string fileName)
99 {
100 m_Target = target;
101
102 if((m_Target & LogTargets.File) != 0)
103 {
104 m_Writer = new StreamWriter(fileName, false);
105 }
106 }
107
108 #endregion
109
110 #region Public Methods
111
112 /// <summary>
113 /// Writes this instance.
114 /// </summary>
115 public void Write()
116 {
117 Write(string.Empty);
118 }
119
120 /// <summary>
121 /// Writes the specified MSG.
122 /// </summary>
123 /// <param name="msg">The MSG.</param>
124 public void Write(string msg)
125 {
126 if((m_Target & LogTargets.Null) != 0)
127 {
128 return;
129 }
130
131 if((m_Target & LogTargets.Console) != 0)
132 {
133 Console.WriteLine(msg);
134 }
135 if((m_Target & LogTargets.File) != 0 && m_Writer != null)
136 {
137 m_Writer.WriteLine(msg);
138 }
139 }
140
141 /// <summary>
142 /// Writes the specified format.
143 /// </summary>
144 /// <param name="format">The format.</param>
145 /// <param name="args">The args.</param>
146 public void Write(string format, params object[] args)
147 {
148 Write(string.Format(format,args));
149 }
150
151 /// <summary>
152 /// Writes the specified type.
153 /// </summary>
154 /// <param name="type">The type.</param>
155 /// <param name="format">The format.</param>
156 /// <param name="args">The args.</param>
157 public void Write(LogType type, string format, params object[] args)
158 {
159 if((m_Target & LogTargets.Null) != 0)
160 {
161 return;
162 }
163
164 string str = "";
165 switch(type)
166 {
167 case LogType.Info:
168 str = "[I] ";
169 break;
170 case LogType.Warning:
171 str = "[!] ";
172 break;
173 case LogType.Error:
174 str = "[X] ";
175 break;
176 }
177
178 Write(str + format,args);
179 }
180
181 /// <summary>
182 /// Writes the exception.
183 /// </summary>
184 /// <param name="type">The type.</param>
185 /// <param name="ex">The ex.</param>
186 public void WriteException(LogType type, Exception ex)
187 {
188 if(ex != null)
189 {
190 Write(type, ex.Message);
191 //#if DEBUG
192 m_Writer.WriteLine("Exception @{0} stack trace [[", ex.TargetSite.Name);
193 m_Writer.WriteLine(ex.StackTrace);
194 m_Writer.WriteLine("]]");
195 //#endif
196 }
197 }
198
199 /// <summary>
200 /// Flushes this instance.
201 /// </summary>
202 public void Flush()
203 {
204 if(m_Writer != null)
205 {
206 m_Writer.Flush();
207 }
208 }
209
210 #endregion
211
212 #region IDisposable Members
213
214 /// <summary>
215 /// Performs application-defined tasks associated with freeing, releasing, or
216 /// resetting unmanaged resources.
217 /// </summary>
218 public void Dispose()
219 {
220 Dispose(true);
221 GC.SuppressFinalize(this);
222 }
223
224 /// <summary>
225 /// Dispose objects
226 /// </summary>
227 /// <param name="disposing">
228 /// If true, it will dispose close the handle
229 /// </param>
230 /// <remarks>
231 /// Will dispose managed and unmanaged resources.
232 /// </remarks>
233 protected virtual void Dispose(bool disposing)
234 {
235 if (!this.disposed)
236 {
237 if (disposing)
238 {
239 if (m_Writer != null)
240 {
241 m_Writer.Close();
242 m_Writer = null;
243 }
244 }
245 }
246 this.disposed = true;
247 }
248
249 /// <summary>
250 ///
251 /// </summary>
252 ~Log()
253 {
254 this.Dispose(false);
255 }
256
257 /// <summary>
258 /// Closes and destroys this object
259 /// </summary>
260 /// <remarks>
261 /// Same as Dispose(true)
262 /// </remarks>
263 public void Close()
264 {
265 Dispose();
266 }
267
268 #endregion
269 }
270}