diff options
-rw-r--r-- | OpenSim/Framework/Console/LocalConsole.cs | 58 | ||||
-rw-r--r-- | OpenSim/Region/Application/OpenSim.cs | 2 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServicesServerBase.cs | 2 | ||||
-rw-r--r-- | bin/OpenSim.ini.example | 13 | ||||
-rw-r--r-- | bin/OpenSimDefaults.ini | 10 | ||||
-rw-r--r-- | bin/Robust.HG.ini.example | 10 | ||||
-rw-r--r-- | bin/Robust.ini.example | 10 |
7 files changed, 101 insertions, 4 deletions
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 260a86f..28293c0 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -32,6 +32,8 @@ using System.Reflection; | |||
32 | using System.Text; | 32 | using System.Text; |
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using System.IO; | ||
36 | using Nini.Config; | ||
35 | using log4net; | 37 | using log4net; |
36 | 38 | ||
37 | namespace OpenSim.Framework.Console | 39 | namespace OpenSim.Framework.Console |
@@ -41,7 +43,9 @@ namespace OpenSim.Framework.Console | |||
41 | /// </summary> | 43 | /// </summary> |
42 | public class LocalConsole : CommandConsole | 44 | public class LocalConsole : CommandConsole |
43 | { | 45 | { |
44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | private string m_historyPath; | ||
48 | private bool m_historyEnable; | ||
45 | 49 | ||
46 | // private readonly object m_syncRoot = new object(); | 50 | // private readonly object m_syncRoot = new object(); |
47 | private const string LOGLEVEL_NONE = "(none)"; | 51 | private const string LOGLEVEL_NONE = "(none)"; |
@@ -79,8 +83,54 @@ namespace OpenSim.Framework.Console | |||
79 | return Colors[(Math.Abs(input.ToUpper().GetHashCode()) % Colors.Length)]; | 83 | return Colors[(Math.Abs(input.ToUpper().GetHashCode()) % Colors.Length)]; |
80 | } | 84 | } |
81 | 85 | ||
82 | public LocalConsole(string defaultPrompt) : base(defaultPrompt) | 86 | public LocalConsole(string defaultPrompt, IConfig startupConfig = null) : base(defaultPrompt) |
83 | { | 87 | { |
88 | |||
89 | if (startupConfig == null) return; | ||
90 | |||
91 | m_historyEnable = startupConfig.GetBoolean("ConsoleHistoryFileEnabled", false); | ||
92 | if (!m_historyEnable) | ||
93 | { | ||
94 | m_log.Info("[LOCAL CONSOLE]: Persistent command line history from file is Disabled"); | ||
95 | return; | ||
96 | } | ||
97 | |||
98 | string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", "OpenSimConsoleHistory.txt"); | ||
99 | int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100); | ||
100 | m_historyPath = Path.GetFullPath(Path.Combine(Util.configDir(), m_historyFile)); | ||
101 | m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1}", m_historySize, m_historyPath); | ||
102 | |||
103 | if (File.Exists(m_historyPath)) | ||
104 | { | ||
105 | using (StreamReader history_file = new StreamReader(m_historyPath)) | ||
106 | { | ||
107 | string line; | ||
108 | while ((line = history_file.ReadLine()) != null) | ||
109 | { | ||
110 | m_history.Add(line); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | if (m_history.Count > m_historySize) | ||
115 | { | ||
116 | while (m_history.Count > m_historySize) | ||
117 | m_history.RemoveAt(0); | ||
118 | |||
119 | using (StreamWriter history_file = new StreamWriter(m_historyPath)) | ||
120 | { | ||
121 | foreach (string line in m_history) | ||
122 | { | ||
123 | history_file.WriteLine(line); | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | m_log.InfoFormat("[LOCAL CONSOLE]: Read {0} lines of command line history from file {1}", m_history.Count, m_historyPath); | ||
128 | } | ||
129 | else | ||
130 | { | ||
131 | m_log.InfoFormat("[LOCAL CONSOLE]: Creating new empty command line history file {0}", m_historyPath); | ||
132 | File.Create(m_historyPath).Dispose(); | ||
133 | } | ||
84 | } | 134 | } |
85 | 135 | ||
86 | private void AddToHistory(string text) | 136 | private void AddToHistory(string text) |
@@ -89,6 +139,10 @@ namespace OpenSim.Framework.Console | |||
89 | m_history.RemoveAt(0); | 139 | m_history.RemoveAt(0); |
90 | 140 | ||
91 | m_history.Add(text); | 141 | m_history.Add(text); |
142 | if (m_historyEnable) | ||
143 | { | ||
144 | File.AppendAllText(m_historyPath, text + Environment.NewLine); | ||
145 | } | ||
92 | } | 146 | } |
93 | 147 | ||
94 | /// <summary> | 148 | /// <summary> |
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index e7f68c2..d5ea3ef 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -155,7 +155,7 @@ namespace OpenSim | |||
155 | ((RemoteConsole)m_console).ReadConfig(Config); | 155 | ((RemoteConsole)m_console).ReadConfig(Config); |
156 | break; | 156 | break; |
157 | default: | 157 | default: |
158 | m_console = new LocalConsole("Region"); | 158 | m_console = new LocalConsole("Region", Config.Configs["Startup"]); |
159 | break; | 159 | break; |
160 | } | 160 | } |
161 | } | 161 | } |
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 8352ee2..86a2551 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs | |||
@@ -158,7 +158,7 @@ namespace OpenSim.Server.Base | |||
158 | } | 158 | } |
159 | else | 159 | else |
160 | { | 160 | { |
161 | MainConsole.Instance = new LocalConsole(prompt); | 161 | MainConsole.Instance = new LocalConsole(prompt, startupConfig); |
162 | } | 162 | } |
163 | 163 | ||
164 | m_console = MainConsole.Instance; | 164 | m_console = MainConsole.Instance; |
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 8c1a2c6..573180a 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -51,6 +51,19 @@ | |||
51 | ;; \\ - substitute \ | 51 | ;; \\ - substitute \ |
52 | ; ConsolePrompt = "Region (\R) " | 52 | ; ConsolePrompt = "Region (\R) " |
53 | 53 | ||
54 | ;# {ConsoleHistoryFileEnabled} {} {Save console commands to a history file?} {true false} true | ||
55 | ;; Console commands can be saved to a file, so the command history persists after a restart. (default is false) | ||
56 | ; ConsoleHistoryFileEnabled = true | ||
57 | |||
58 | ;# {ConsoleHistoryFile} {} {Filename in which to save history} {} OpenSimConsoleHistory.txt | ||
59 | ;; The history file can be just a filename (relative to OpenSim's bin/ directory | ||
60 | ;; or it can be a full path to somewhere else. (default is OpenSimConsoleHistory.txt in bin/) | ||
61 | ; ConsoleHistoryFile = "OpenSimConsoleHistory.txt" | ||
62 | |||
63 | ;# {ConsoleHistoryFileLines} {} {How many lines of history to save?} {} 100 | ||
64 | ;; How many lines of command history should we keep? (default is 100) | ||
65 | ; ConsoleHistoryFileLines = 100 | ||
66 | |||
54 | ;# {save_crashes} {} {Save crashes to disk?} {true false} false | 67 | ;# {save_crashes} {} {Save crashes to disk?} {true false} false |
55 | ;; Set this to true if you want to log crashes to disk | 68 | ;; Set this to true if you want to log crashes to disk |
56 | ;; this can be useful when submitting bug reports. | 69 | ;; this can be useful when submitting bug reports. |
diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 5361e8d..c6250e5 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini | |||
@@ -9,6 +9,16 @@ | |||
9 | ; \\ - substtitue \ | 9 | ; \\ - substtitue \ |
10 | ConsolePrompt = "Region (\R) " | 10 | ConsolePrompt = "Region (\R) " |
11 | 11 | ||
12 | ; Console commands can be saved to a file, so the command history persists after a restart. (default is true) | ||
13 | ConsoleHistoryFileEnabled = true | ||
14 | |||
15 | ; The history file can be just a filename (relative to OpenSim's bin/ directory | ||
16 | ; or it can be a full path to somewhere else. (default is OpenSimConsoleHistory.txt in bin/) | ||
17 | ConsoleHistoryFile = "OpenSimConsoleHistory.txt" | ||
18 | |||
19 | ; How many lines of command history should we keep? (default is 100) | ||
20 | ConsoleHistoryFileLines = 100 | ||
21 | |||
12 | ; Set this to true if you want to log crashes to disk | 22 | ; Set this to true if you want to log crashes to disk |
13 | ; this can be useful when submitting bug reports. | 23 | ; this can be useful when submitting bug reports. |
14 | ; However, this will only log crashes within OpenSimulator that cause the entire program to exit | 24 | ; However, this will only log crashes within OpenSimulator that cause the entire program to exit |
diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index edcbec3..ef6f080 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example | |||
@@ -37,6 +37,16 @@ | |||
37 | ; The Robust.exe process must have R/W access to the location | 37 | ; The Robust.exe process must have R/W access to the location |
38 | ConfigDirectory = "." | 38 | ConfigDirectory = "." |
39 | 39 | ||
40 | ; Console commands can be saved to a file, so the command history persists after a restart. (default is true) | ||
41 | ConsoleHistoryFileEnabled = true | ||
42 | |||
43 | ; The history file can be just a filename (relative to OpenSim's bin/ directory | ||
44 | ; or it can be a full path to somewhere else. (default is OpenSimConsoleHistory.txt in bin/) | ||
45 | ConsoleHistoryFile = "RobustConsoleHistory.txt" | ||
46 | |||
47 | ; How many lines of command history should we keep? (default is 100) | ||
48 | ConsoleHistoryFileLines = 100 | ||
49 | |||
40 | [ServiceList] | 50 | [ServiceList] |
41 | 51 | ||
42 | AssetServiceConnector = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector" | 52 | AssetServiceConnector = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector" |
diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 6686c3f..ca0b699 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example | |||
@@ -28,7 +28,17 @@ | |||
28 | ; Set path to directory for modular ini files... | 28 | ; Set path to directory for modular ini files... |
29 | ; The Robust.exe process must have R/W access to the location | 29 | ; The Robust.exe process must have R/W access to the location |
30 | ConfigDirectory = "." | 30 | ConfigDirectory = "." |
31 | |||
32 | ; Console commands can be saved to a file, so the command history persists after a restart. (default is true) | ||
33 | ConsoleHistoryFileEnabled = true | ||
31 | 34 | ||
35 | ; The history file can be just a filename (relative to OpenSim's bin/ directory | ||
36 | ; or it can be a full path to somewhere else. (default is OpenSimConsoleHistory.txt in bin/) | ||
37 | ConsoleHistoryFile = "RobustConsoleHistory.txt" | ||
38 | |||
39 | ; How many lines of command history should we keep? (default is 100) | ||
40 | ConsoleHistoryFileLines = 100 | ||
41 | |||
32 | [ServiceList] | 42 | [ServiceList] |
33 | AssetServiceConnector = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector" | 43 | AssetServiceConnector = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector" |
34 | InventoryInConnector = "8003/OpenSim.Server.Handlers.dll:XInventoryInConnector" | 44 | InventoryInConnector = "8003/OpenSim.Server.Handlers.dll:XInventoryInConnector" |