aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Console
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Console')
-rw-r--r--OpenSim/Framework/Console/AssemblyInfo.cs58
-rw-r--r--OpenSim/Framework/Console/ConsoleCallbacksBase.cs39
-rw-r--r--OpenSim/Framework/Console/LogBase.cs238
-rw-r--r--OpenSim/Framework/Console/MainLog.cs49
-rw-r--r--OpenSim/Framework/Console/OpenSim.Framework.Console.csproj89
-rw-r--r--OpenSim/Framework/Console/OpenSim.Framework.Console.csproj.user12
6 files changed, 485 insertions, 0 deletions
diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs
new file mode 100644
index 0000000..8f715d2
--- /dev/null
+++ b/OpenSim/Framework/Console/AssemblyInfo.cs
@@ -0,0 +1,58 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// Information about this assembly is defined by the following
33// attributes.
34//
35// change them to the information which is associated with the assembly
36// you compile.
37
38[assembly: AssemblyTitle("ServerConsole")]
39[assembly: AssemblyDescription("")]
40[assembly: AssemblyConfiguration("")]
41[assembly: AssemblyCompany("")]
42[assembly: AssemblyProduct("ServerConsole")]
43[assembly: AssemblyCopyright("")]
44[assembly: AssemblyTrademark("")]
45[assembly: AssemblyCulture("")]
46
47// This sets the default COM visibility of types in the assembly to invisible.
48// If you need to expose a type to COM, use [ComVisible(true)] on that type.
49[assembly: ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Framework/Console/ConsoleCallbacksBase.cs b/OpenSim/Framework/Console/ConsoleCallbacksBase.cs
new file mode 100644
index 0000000..e3847be
--- /dev/null
+++ b/OpenSim/Framework/Console/ConsoleCallbacksBase.cs
@@ -0,0 +1,39 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Framework.Console
33{
34 public interface conscmd_callback
35 {
36 void RunCmd(string cmd, string[] cmdparams);
37 void Show(string ShowWhat);
38 }
39}
diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs
new file mode 100644
index 0000000..1a92d8e
--- /dev/null
+++ b/OpenSim/Framework/Console/LogBase.cs
@@ -0,0 +1,238 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.IO;
30
31namespace OpenSim.Framework.Console
32{
33 public enum LogPriority : int
34 {
35 CRITICAL,
36 HIGH,
37 MEDIUM,
38 NORMAL,
39 LOW,
40 VERBOSE,
41 EXTRAVERBOSE
42 }
43
44 public class LogBase
45 {
46 StreamWriter Log;
47 public conscmd_callback cmdparser;
48 public string componentname;
49 private bool m_silent;
50
51 public LogBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent )
52 {
53 this.componentname = componentname;
54 this.cmdparser = cmdparser;
55 this.m_silent = silent;
56 System.Console.WriteLine("ServerConsole.cs - creating new local console");
57
58 if( String.IsNullOrEmpty( LogFile ) )
59 {
60 LogFile = componentname + ".log";
61 }
62
63 System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
64 Log = File.AppendText(LogFile);
65 Log.WriteLine("========================================================================");
66 Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
67 }
68
69 public void Close()
70 {
71 Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
72 Log.Close();
73 }
74
75 public void Write(string format, params object[] args)
76 {
77 Notice(format,args);
78 return;
79 }
80
81 public void WriteLine(LogPriority importance, string format, params object[] args)
82 {
83 Log.WriteLine(format, args);
84 Log.Flush();
85 if (!m_silent)
86 {
87 System.Console.WriteLine(format, args);
88 }
89 return;
90 }
91
92 public void Warn(string format, params object[] args)
93 {
94 WriteNewLine(ConsoleColor.Yellow, format, args);
95 return;
96 }
97
98 public void Notice(string format, params object[] args)
99 {
100 WriteNewLine(ConsoleColor.White, format, args);
101 return;
102 }
103
104 public void Error(string format, params object[] args)
105 {
106 WriteNewLine(ConsoleColor.Red, format, args);
107 return;
108 }
109
110 public void Verbose(string format, params object[] args)
111 {
112 WriteNewLine(ConsoleColor.Gray, format, args);
113 return;
114 }
115
116 public void Status(string format, params object[] args)
117 {
118 WriteNewLine(ConsoleColor.Blue, format, args);
119 return;
120 }
121
122 private void WriteNewLine(System.ConsoleColor color, string format, params object[] args)
123 {
124 Log.WriteLine(format, args);
125 Log.Flush();
126 if (!m_silent)
127 {
128 try
129 {
130 System.Console.ForegroundColor = color;
131 System.Console.WriteLine(format, args);
132 System.Console.ResetColor();
133 }
134 catch (System.ArgumentNullException)
135 {
136 // Some older systems dont support coloured text.
137 System.Console.WriteLine(format, args);
138 }
139 }
140 return;
141 }
142
143 public string ReadLine()
144 {
145 string TempStr = System.Console.ReadLine();
146 Log.WriteLine(TempStr);
147 return TempStr;
148 }
149
150 public int Read()
151 {
152 int TempInt = System.Console.Read();
153 Log.Write((char)TempInt);
154 return TempInt;
155 }
156
157 // Displays a prompt and waits for the user to enter a string, then returns that string
158 // Done with no echo and suitable for passwords
159 public string PasswdPrompt(string prompt)
160 {
161 // FIXME: Needs to be better abstracted
162 Log.WriteLine(prompt);
163 this.Write(prompt);
164 ConsoleColor oldfg = System.Console.ForegroundColor;
165 System.Console.ForegroundColor = System.Console.BackgroundColor;
166 string temp = System.Console.ReadLine();
167 System.Console.ForegroundColor = oldfg;
168 return temp;
169 }
170
171 // Displays a command prompt and waits for the user to enter a string, then returns that string
172 public string CmdPrompt(string prompt)
173 {
174 this.Write(String.Format("{0}: ", prompt));
175 return this.ReadLine();
176 }
177
178 // Displays a command prompt and returns a default value if the user simply presses enter
179 public string CmdPrompt(string prompt, string defaultresponse)
180 {
181 string temp = CmdPrompt(String.Format( "{0} [{1}]", prompt, defaultresponse ));
182 if (temp == "")
183 {
184 return defaultresponse;
185 }
186 else
187 {
188 return temp;
189 }
190 }
191
192 // Displays a command prompt and returns a default value, user may only enter 1 of 2 options
193 public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB)
194 {
195 bool itisdone = false;
196 string temp = CmdPrompt(prompt, defaultresponse);
197 while (itisdone == false)
198 {
199 if ((temp == OptionA) || (temp == OptionB))
200 {
201 itisdone = true;
202 }
203 else
204 {
205 Notice("Valid options are " + OptionA + " or " + OptionB);
206 temp = CmdPrompt(prompt, defaultresponse);
207 }
208 }
209 return temp;
210 }
211
212 // Runs a command with a number of parameters
213 public Object RunCmd(string Cmd, string[] cmdparams)
214 {
215 cmdparser.RunCmd(Cmd, cmdparams);
216 return null;
217 }
218
219 // Shows data about something
220 public void ShowCommands(string ShowWhat)
221 {
222 cmdparser.Show(ShowWhat);
223 }
224
225 public void MainLogPrompt()
226 {
227 string[] tempstrarray;
228 string tempstr = this.CmdPrompt(this.componentname + "# ");
229 tempstrarray = tempstr.Split(' ');
230 string cmd = tempstrarray[0];
231 Array.Reverse(tempstrarray);
232 Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
233 Array.Reverse(tempstrarray);
234 string[] cmdparams = (string[])tempstrarray;
235 RunCmd(cmd, cmdparams);
236 }
237 }
238}
diff --git a/OpenSim/Framework/Console/MainLog.cs b/OpenSim/Framework/Console/MainLog.cs
new file mode 100644
index 0000000..d7f945e
--- /dev/null
+++ b/OpenSim/Framework/Console/MainLog.cs
@@ -0,0 +1,49 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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;
29
30namespace OpenSim.Framework.Console
31{
32 public class MainLog {
33
34 private static LogBase instance;
35
36 public static LogBase Instance
37 {
38 get
39 {
40 return instance;
41 }
42 set
43 {
44 instance = value;
45 }
46 }
47 }
48
49}
diff --git a/OpenSim/Framework/Console/OpenSim.Framework.Console.csproj b/OpenSim/Framework/Console/OpenSim.Framework.Console.csproj
new file mode 100644
index 0000000..f3dcec5
--- /dev/null
+++ b/OpenSim/Framework/Console/OpenSim.Framework.Console.csproj
@@ -0,0 +1,89 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{A7CD0630-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Framework.Console</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Framework.Console</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 </ItemGroup>
66 <ItemGroup>
67 </ItemGroup>
68 <ItemGroup>
69 <Compile Include="AssemblyInfo.cs">
70 <SubType>Code</SubType>
71 </Compile>
72 <Compile Include="ConsoleCallbacksBase.cs">
73 <SubType>Code</SubType>
74 </Compile>
75 <Compile Include="LogBase.cs">
76 <SubType>Code</SubType>
77 </Compile>
78 <Compile Include="MainLog.cs">
79 <SubType>Code</SubType>
80 </Compile>
81 </ItemGroup>
82 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
83 <PropertyGroup>
84 <PreBuildEvent>
85 </PreBuildEvent>
86 <PostBuildEvent>
87 </PostBuildEvent>
88 </PropertyGroup>
89</Project>
diff --git a/OpenSim/Framework/Console/OpenSim.Framework.Console.csproj.user b/OpenSim/Framework/Console/OpenSim.Framework.Console.csproj.user
new file mode 100644
index 0000000..6841907
--- /dev/null
+++ b/OpenSim/Framework/Console/OpenSim.Framework.Console.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-06\NameSpaceChanges\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>