aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
diff options
context:
space:
mode:
authorJeff Ames2009-02-22 01:26:18 +0000
committerJeff Ames2009-02-22 01:26:18 +0000
commit818af9d4827ea66358abbc3929d20e09861c7306 (patch)
tree097254f7d203fff8547c30061540bc01e4f84d12 /OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
parentAddresses some issues with appearance after TPs. Appearance.Owner was not bei... (diff)
downloadopensim-SC_OLD-818af9d4827ea66358abbc3929d20e09861c7306.zip
opensim-SC_OLD-818af9d4827ea66358abbc3929d20e09861c7306.tar.gz
opensim-SC_OLD-818af9d4827ea66358abbc3929d20e09861c7306.tar.bz2
opensim-SC_OLD-818af9d4827ea66358abbc3929d20e09861c7306.tar.xz
Refactor log4net logger handling in script engine. (#3148)
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs44
1 files changed, 21 insertions, 23 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 5b3dce7..03b2ab3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -29,10 +29,12 @@ using System;
29using System.CodeDom.Compiler; 29using System.CodeDom.Compiler;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Globalization; 31using System.Globalization;
32using System.Reflection;
32using System.IO; 33using System.IO;
33using Microsoft.CSharp; 34using Microsoft.CSharp;
34using Microsoft.JScript; 35using Microsoft.JScript;
35using Microsoft.VisualBasic; 36using Microsoft.VisualBasic;
37using log4net;
36using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.ScriptEngine.Interfaces; 39using OpenSim.Region.ScriptEngine.Interfaces;
38 40
@@ -40,8 +42,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
40{ 42{
41 public class Compiler : ICompiler 43 public class Compiler : ICompiler
42 { 44 {
43 // private static readonly log4net.ILog m_log 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
45 46
46 // * Uses "LSL2Converter" to convert LSL to C# if necessary. 47 // * Uses "LSL2Converter" to convert LSL to C# if necessary.
47 // * Compiles C#-code into an assembly 48 // * Compiles C#-code into an assembly
@@ -126,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
126 AllowedCompilers.Clear(); 127 AllowedCompilers.Clear();
127 128
128#if DEBUG 129#if DEBUG
129 m_scriptEngine.Log.Debug("[Compiler]: Allowed languages: " + allowComp); 130 m_log.Debug("[Compiler]: Allowed languages: " + allowComp);
130#endif 131#endif
131 132
132 133
@@ -135,18 +136,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
135 string strlan = strl.Trim(" \t".ToCharArray()).ToLower(); 136 string strlan = strl.Trim(" \t".ToCharArray()).ToLower();
136 if (!LanguageMapping.ContainsKey(strlan)) 137 if (!LanguageMapping.ContainsKey(strlan))
137 { 138 {
138 m_scriptEngine.Log.Error("[Compiler]: Config error. Compiler is unable to recognize language type \"" + strlan + "\" specified in \"AllowedCompilers\"."); 139 m_log.Error("[Compiler]: Config error. Compiler is unable to recognize language type \"" + strlan + "\" specified in \"AllowedCompilers\".");
139 } 140 }
140 else 141 else
141 { 142 {
142#if DEBUG 143#if DEBUG
143 //m_scriptEngine.Log.Debug("[Compiler]: Config OK. Compiler recognized language type \"" + strlan + "\" specified in \"AllowedCompilers\"."); 144 //m_log.Debug("[Compiler]: Config OK. Compiler recognized language type \"" + strlan + "\" specified in \"AllowedCompilers\".");
144#endif 145#endif
145 } 146 }
146 AllowedCompilers.Add(strlan, true); 147 AllowedCompilers.Add(strlan, true);
147 } 148 }
148 if (AllowedCompilers.Count == 0) 149 if (AllowedCompilers.Count == 0)
149 m_scriptEngine.Log.Error("[Compiler]: Config error. Compiler could not recognize any language in \"AllowedCompilers\". Scripts will not be executed!"); 150 m_log.Error("[Compiler]: Config error. Compiler could not recognize any language in \"AllowedCompilers\". Scripts will not be executed!");
150 151
151 // Default language 152 // Default language
152 string defaultCompileLanguage = m_scriptEngine.Config.GetString("DefaultCompileLanguage", "lsl").ToLower(); 153 string defaultCompileLanguage = m_scriptEngine.Config.GetString("DefaultCompileLanguage", "lsl").ToLower();
@@ -154,7 +155,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
154 // Is this language recognized at all? 155 // Is this language recognized at all?
155 if (!LanguageMapping.ContainsKey(defaultCompileLanguage)) 156 if (!LanguageMapping.ContainsKey(defaultCompileLanguage))
156 { 157 {
157 m_scriptEngine.Log.Error("[Compiler]: " + 158 m_log.Error("[Compiler]: " +
158 "Config error. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is not recognized as a valid language. Changing default to: \"lsl\"."); 159 "Config error. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is not recognized as a valid language. Changing default to: \"lsl\".");
159 defaultCompileLanguage = "lsl"; 160 defaultCompileLanguage = "lsl";
160 } 161 }
@@ -162,13 +163,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
162 // Is this language in allow-list? 163 // Is this language in allow-list?
163 if (!AllowedCompilers.ContainsKey(defaultCompileLanguage)) 164 if (!AllowedCompilers.ContainsKey(defaultCompileLanguage))
164 { 165 {
165 m_scriptEngine.Log.Error("[Compiler]: " + 166 m_log.Error("[Compiler]: " +
166 "Config error. Default language \"" + defaultCompileLanguage + "\"specified in \"DefaultCompileLanguage\" is not in list of \"AllowedCompilers\". Scripts may not be executed!"); 167 "Config error. Default language \"" + defaultCompileLanguage + "\"specified in \"DefaultCompileLanguage\" is not in list of \"AllowedCompilers\". Scripts may not be executed!");
167 } 168 }
168 else 169 else
169 { 170 {
170#if DEBUG 171#if DEBUG
171// m_scriptEngine.Log.Debug("[Compiler]: " + 172// m_log.Debug("[Compiler]: " +
172// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language."); 173// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language.");
173#endif 174#endif
174 // LANGUAGE IS IN ALLOW-LIST 175 // LANGUAGE IS IN ALLOW-LIST
@@ -194,7 +195,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
194 } 195 }
195 catch (Exception ex) 196 catch (Exception ex)
196 { 197 {
197 m_scriptEngine.Log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + ScriptEnginesPath + "\": " + ex.ToString()); 198 m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + ScriptEnginesPath + "\": " + ex.ToString());
198 } 199 }
199 } 200 }
200 201
@@ -208,7 +209,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
208 } 209 }
209 catch (Exception ex) 210 catch (Exception ex)
210 { 211 {
211 m_scriptEngine.Log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath, 212 m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath,
212 m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString()); 213 m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString());
213 } 214 }
214 } 215 }
@@ -216,7 +217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
216 foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath, 217 foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath,
217 m_scriptEngine.World.RegionInfo.RegionID.ToString()))) 218 m_scriptEngine.World.RegionInfo.RegionID.ToString())))
218 { 219 {
219 //m_scriptEngine.Log.Error("[Compiler]: FILE FOUND: " + file); 220 //m_log.Error("[Compiler]: FILE FOUND: " + file);
220 221
221 if (file.ToLower().StartsWith(FilePrefix + "_compiled_") || 222 if (file.ToLower().StartsWith(FilePrefix + "_compiled_") ||
222 file.ToLower().StartsWith(FilePrefix + "_source_")) 223 file.ToLower().StartsWith(FilePrefix + "_source_"))
@@ -227,12 +228,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
227 } 228 }
228 catch (Exception ex) 229 catch (Exception ex)
229 { 230 {
230 m_scriptEngine.Log.Error("[Compiler]: Exception trying delete old script file \"" + file + "\": " + ex.ToString()); 231 m_log.Error("[Compiler]: Exception trying delete old script file \"" + file + "\": " + ex.ToString());
231 } 232 }
232
233 } 233 }
234 } 234 }
235
236 } 235 }
237 236
238 ////private ICodeCompiler icc = codeProvider.CreateCompiler(); 237 ////private ICodeCompiler icc = codeProvider.CreateCompiler();
@@ -293,9 +292,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
293 if (Script == String.Empty) 292 if (Script == String.Empty)
294 { 293 {
295 if (File.Exists(OutFile)) 294 if (File.Exists(OutFile))
296
297 { 295 {
298// m_scriptEngine.Log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset); 296// m_log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset);
299 return OutFile; 297 return OutFile;
300 } 298 }
301 299
@@ -345,7 +343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
345 // 343 //
346 if (File.Exists(OutFile) && File.Exists(OutFile+".text")) 344 if (File.Exists(OutFile) && File.Exists(OutFile+".text"))
347 { 345 {
348// m_scriptEngine.Log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset); 346// m_log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset);
349 return OutFile; 347 return OutFile;
350 } 348 }
351 349
@@ -465,9 +463,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
465 } 463 }
466 catch (Exception ex) //NOTLEGIT - Should be just FileIOException 464 catch (Exception ex) //NOTLEGIT - Should be just FileIOException
467 { 465 {
468 m_scriptEngine.Log.Error("[Compiler]: Exception while "+ 466 m_log.Error("[Compiler]: Exception while "+
469 "trying to write script source to file \"" + 467 "trying to write script source to file \"" +
470 srcFileName + "\": " + ex.ToString()); 468 srcFileName + "\": " + ex.ToString());
471 } 469 }
472 } 470 }
473 471
@@ -577,7 +575,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
577 errtext += "No compile error. But not able to locate compiled file."; 575 errtext += "No compile error. But not able to locate compiled file.";
578 throw new Exception(errtext); 576 throw new Exception(errtext);
579 } 577 }
580// m_scriptEngine.Log.DebugFormat("[Compiler] Compiled new assembly "+ 578// m_log.DebugFormat("[Compiler] Compiled new assembly "+
581// "for {0}", asset); 579// "for {0}", asset);
582 580
583 // Because windows likes to perform exclusive locks, we simply 581 // Because windows likes to perform exclusive locks, we simply