aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLLogData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLLogData.cs146
1 files changed, 0 insertions, 146 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLLogData.cs b/OpenSim/Data/MSSQL/MSSQLLogData.cs
deleted file mode 100644
index 72c50e6..0000000
--- a/OpenSim/Data/MSSQL/MSSQLLogData.cs
+++ /dev/null
@@ -1,146 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using log4net;
31using OpenSim.Framework;
32
33namespace OpenSim.Data.MSSQL
34{
35 /// <summary>
36 /// An interface to the log database for MSSQL
37 /// </summary>
38 internal class MSSQLLogData : ILogDataPlugin
39 {
40 private const string _migrationStore = "LogStore";
41
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
44 /// <summary>
45 /// The database manager
46 /// </summary>
47 public MSSQLManager database;
48
49 [Obsolete("Cannot be default-initialized!")]
50 public void Initialise()
51 {
52 m_log.Info("[LOG DB]: " + Name + " cannot be default-initialized!");
53 throw new PluginNotInitialisedException (Name);
54 }
55
56 /// <summary>
57 /// Artificial constructor called when the plugin is loaded
58 /// </summary>
59 public void Initialise(string connect)
60 {
61 if (!string.IsNullOrEmpty(connect))
62 {
63 database = new MSSQLManager(connect);
64 }
65 else
66 {
67 // TODO: do something with the connect string
68 IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini");
69 string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
70 string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
71 string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
72 string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
73 string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
74
75 database =
76 new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
77 settingPassword);
78 }
79
80 //Updating mechanisme
81 database.CheckMigration(_migrationStore);
82 }
83
84 /// <summary>
85 /// Saves a log item to the database
86 /// </summary>
87 /// <param name="serverDaemon">The daemon triggering the event</param>
88 /// <param name="target">The target of the action (region / agent UUID, etc)</param>
89 /// <param name="methodCall">The method call where the problem occured</param>
90 /// <param name="arguments">The arguments passed to the method</param>
91 /// <param name="priority">How critical is this?</param>
92 /// <param name="logMessage">The message to log</param>
93 public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
94 string logMessage)
95 {
96 string sql = "INSERT INTO logs ([target], [server], [method], [arguments], [priority], [message]) VALUES ";
97 sql += "(@target, @server, @method, @arguments, @priority, @message);";
98
99 using (AutoClosingSqlCommand command = database.Query(sql))
100 {
101 command.Parameters.Add(database.CreateParameter("server", serverDaemon));
102 command.Parameters.Add(database.CreateParameter("target",target));
103 command.Parameters.Add(database.CreateParameter("method", methodCall));
104 command.Parameters.Add(database.CreateParameter("arguments", arguments));
105 command.Parameters.Add(database.CreateParameter("priority", priority.ToString()));
106 command.Parameters.Add(database.CreateParameter("message", logMessage));
107
108 try
109 {
110 command.ExecuteNonQuery();
111 }
112 catch (Exception e)
113 {
114 //Are we not in a loop here
115 m_log.Error("[LOG DB] Error logging : " + e.Message);
116 }
117 }
118 }
119
120 /// <summary>
121 /// Returns the name of this DB provider
122 /// </summary>
123 /// <returns>A string containing the DB provider name</returns>
124 public string Name
125 {
126 get { return "MSSQL Logdata Interface"; }
127 }
128
129 /// <summary>
130 /// Closes the database provider
131 /// </summary>
132 public void Dispose()
133 {
134 database = null;
135 }
136
137 /// <summary>
138 /// Returns the version of this DB provider
139 /// </summary>
140 /// <returns>A string containing the provider version</returns>
141 public string Version
142 {
143 get { return "0.1"; }
144 }
145 }
146}