diff options
Diffstat (limited to 'OpenSim/Region/UserStatistics/LogLinesAJAX.cs')
-rw-r--r-- | OpenSim/Region/UserStatistics/LogLinesAJAX.cs | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/OpenSim/Region/UserStatistics/LogLinesAJAX.cs b/OpenSim/Region/UserStatistics/LogLinesAJAX.cs new file mode 100644 index 0000000..9626c12 --- /dev/null +++ b/OpenSim/Region/UserStatistics/LogLinesAJAX.cs | |||
@@ -0,0 +1,98 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Reflection; | ||
5 | using System.Text; | ||
6 | using System.Text.RegularExpressions; | ||
7 | using Mono.Data.SqliteClient; | ||
8 | using OpenMetaverse; | ||
9 | using OpenSim.Region.Environment.Scenes; | ||
10 | using OpenSim.Framework.Statistics; | ||
11 | |||
12 | namespace OpenSim.Region.UserStatistics | ||
13 | { | ||
14 | public class LogLinesAJAX : IStatsController | ||
15 | { | ||
16 | private Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); | ||
17 | |||
18 | private Regex webFormat = new Regex(@"[^\s]*\s([^,]*),[^\s]*\s([A-Z]*)[^\s-][^\[]*\[([^\]]*)\]([^\n]*)", | ||
19 | RegexOptions.Singleline | RegexOptions.Compiled); | ||
20 | private Regex TitleColor = new Regex(@"[^\s]*\s(?:[^,]*),[^\s]*\s(?:[A-Z]*)[^\s-][^\[]*\[([^\]]*)\](?:[^\n]*)", | ||
21 | RegexOptions.Singleline | RegexOptions.Compiled); | ||
22 | |||
23 | |||
24 | #region IStatsController Members | ||
25 | |||
26 | public Hashtable ProcessModel(Hashtable pParams) | ||
27 | { | ||
28 | Hashtable nh = new Hashtable(); | ||
29 | nh.Add("loglines", pParams["LogLines"]); | ||
30 | return nh; | ||
31 | } | ||
32 | |||
33 | public string RenderView(Hashtable pModelResult) | ||
34 | { | ||
35 | StringBuilder output = new StringBuilder(); | ||
36 | |||
37 | HTMLUtil.HR(ref output, ""); | ||
38 | output.Append("<H3>ActiveLog</H3>\n"); | ||
39 | |||
40 | string tmp = normalizeEndLines.Replace(pModelResult["loglines"].ToString(), "\n"); | ||
41 | |||
42 | string[] result = Regex.Split(tmp, "\n"); | ||
43 | |||
44 | string formatopen = ""; | ||
45 | string formatclose = ""; | ||
46 | |||
47 | for (int i = 0; i < result.Length;i++ ) | ||
48 | { | ||
49 | if (result[i].Length >= 30) | ||
50 | { | ||
51 | string logtype = result[i].Substring(24, 6); | ||
52 | switch (logtype) | ||
53 | { | ||
54 | case "WARN ": | ||
55 | formatopen = "<font color=\"#7D7C00\">"; | ||
56 | formatclose = "</font>"; | ||
57 | break; | ||
58 | |||
59 | case "ERROR ": | ||
60 | formatopen = "<font color=\"#FF0000\">"; | ||
61 | formatclose = "</font>"; | ||
62 | break; | ||
63 | |||
64 | default: | ||
65 | formatopen = ""; | ||
66 | formatclose = ""; | ||
67 | break; | ||
68 | |||
69 | } | ||
70 | } | ||
71 | StringBuilder replaceStr = new StringBuilder(); | ||
72 | //string titlecolorresults = | ||
73 | |||
74 | string formatresult = Regex.Replace(TitleColor.Replace(result[i], "$1"), "[^ABCDEFabcdef0-9]", ""); | ||
75 | if (formatresult.Length > 6) | ||
76 | { | ||
77 | formatresult = formatresult.Substring(0, 6); | ||
78 | |||
79 | } | ||
80 | for (int j = formatresult.Length; j <= 5; j++) | ||
81 | formatresult += "0"; | ||
82 | replaceStr.Append("$1 - [<font color=\"#"); | ||
83 | replaceStr.Append(formatresult); | ||
84 | replaceStr.Append("\">$3</font>] $4<br />"); | ||
85 | string repstr = replaceStr.ToString(); | ||
86 | |||
87 | output.Append(formatopen); | ||
88 | output.Append(webFormat.Replace(result[i], repstr)); | ||
89 | output.Append(formatclose); | ||
90 | } | ||
91 | |||
92 | |||
93 | return output.ToString(); | ||
94 | } | ||
95 | |||
96 | #endregion | ||
97 | } | ||
98 | } | ||