Skip to content

Commit a089ec6

Browse files
committed
Color-coded log messages in ServerGUI, made links clickable.
Log messages should be easier to copy, since auto-scrolling is disabled if user is selecting text, and addition of new messages does not affect the current selection.
1 parent 2ee17cf commit a089ec6

File tree

12 files changed

+101
-59
lines changed

12 files changed

+101
-59
lines changed

CHANGELOG.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
Feature: Added {PLAYER_LIST} variable, for use in greetings/announcements/rules.
55
Fix: Fixed changes to DefaultBackupInterval config key not being applied.
66
Fix: Fixed /BanInfo showing "players on same IP" for players without a recorded IP address.
7-
Fix: Fixed /WSet only saving the first word of the greeting message.
87
Fix: Fixed fCraft occasionally using localized datetime and number formatting.
98
Fix: Fixed /Cut storing the selected blocks before checking player's draw limit (thanks ruggedbear).
109
Fix: Fixed /Fill2D starting a selection even if command parameters could not be parsed (thanks David00143).

ConfigGUI/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion( "0.6.2.1" )]
37-
[assembly: AssemblyFileVersion( "0.6.2.1" )]
36+
[assembly: AssemblyVersion( "0.6.2.2" )]
37+
[assembly: AssemblyFileVersion( "0.6.2.2" )]
3838

3939
[assembly: CLSCompliant( false )]
4040
[assembly: NeutralResourcesLanguage( "en-US" )]

ServerCLI/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion( "0.6.2.1" )]
37-
[assembly: AssemblyFileVersion( "0.6.2.1" )]
36+
[assembly: AssemblyVersion( "0.6.2.2" )]
37+
[assembly: AssemblyFileVersion( "0.6.2.2" )]
3838

3939
[assembly: CLSCompliant( true )]
4040
[assembly: NeutralResourcesLanguage( "en-US" )]

ServerGUI/MainForm.Designer.cs

Lines changed: 21 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ServerGUI/MainForm.cs

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ namespace fCraft.ServerGUI {
1313

1414
public sealed partial class MainForm : Form {
1515
volatile bool shutdownPending, startupComplete, shutdownComplete;
16-
const int MaxLinesInLog = 2000;
16+
const int MaxLinesInLog = 2000,
17+
LinesToTrimWhenExceeded = 50;
1718

1819
public MainForm() {
1920
InitializeComponent();
@@ -173,15 +174,55 @@ public void OnLogged( object sender, LogEventArgs e ) {
173174
if( logBox.InvokeRequired ) {
174175
BeginInvoke( (EventHandler<LogEventArgs>)OnLogged, sender, e );
175176
} else {
176-
logBox.AppendText( e.Message + Environment.NewLine );
177+
// store user's selection
178+
int userSelectionStart = logBox.SelectionStart;
179+
int userSelectionLength = logBox.SelectionLength;
180+
bool userSelecting = (logBox.SelectionStart != logBox.Text.Length && logBox.Focused || logBox.SelectionLength > 0);
181+
182+
// insert and color a new message
183+
int oldLength = logBox.Text.Length;
184+
string msgToAppend = e.Message + Environment.NewLine;
185+
logBox.AppendText( msgToAppend );
186+
logBox.Select( oldLength, msgToAppend.Length );
187+
switch( e.MessageType ) {
188+
case LogType.Warning:
189+
logBox.SelectionColor = System.Drawing.Color.Yellow;
190+
break;
191+
case LogType.Debug:
192+
logBox.SelectionColor = System.Drawing.Color.DarkGray;
193+
break;
194+
case LogType.Error:
195+
case LogType.SeriousError:
196+
logBox.SelectionColor = System.Drawing.Color.Red;
197+
break;
198+
case LogType.ConsoleInput:
199+
case LogType.ConsoleOutput:
200+
logBox.SelectionColor = System.Drawing.Color.White;
201+
break;
202+
default:
203+
logBox.SelectionColor = System.Drawing.Color.LightGray;
204+
break;
205+
}
206+
207+
// cut off the log, if too long
177208
if( logBox.Lines.Length > MaxLinesInLog ) {
178-
logBox.Text = "----- cut off, see fCraft.log for complete log -----" +
179-
Environment.NewLine +
180-
logBox.Text.Substring( logBox.GetFirstCharIndexFromLine( 50 ) );
209+
logBox.SelectionStart = 0;
210+
logBox.SelectionLength = logBox.GetFirstCharIndexFromLine( LinesToTrimWhenExceeded );
211+
userSelectionStart -= logBox.SelectionLength;
212+
if( userSelectionStart < 0 ) userSelecting = false;
213+
string textToAdd = "----- cut off, see " + Logger.CurrentLogFileName + " for complete log -----" + Environment.NewLine;
214+
logBox.SelectedText = textToAdd;
215+
userSelectionStart += textToAdd.Length;
216+
logBox.SelectionColor = System.Drawing.Color.DarkGray;
217+
}
218+
219+
// either restore user's selection, or scroll to end
220+
if( userSelecting ) {
221+
logBox.Select( userSelectionStart, userSelectionLength );
222+
} else {
223+
logBox.SelectionStart = logBox.Text.Length;
224+
logBox.ScrollToCaret();
181225
}
182-
logBox.SelectionStart = logBox.Text.Length;
183-
logBox.ScrollToCaret();
184-
if( !Server.IsRunning || shutdownPending ) logBox.Refresh();
185226
}
186227
} catch( ObjectDisposedException ) {
187228
} catch( InvalidOperationException ) { }

ServerGUI/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion( "0.6.2.1" )]
37-
[assembly: AssemblyFileVersion( "0.6.2.1" )]
36+
[assembly: AssemblyVersion( "0.6.2.2" )]
37+
[assembly: AssemblyFileVersion( "0.6.2.2" )]
3838

3939
[assembly: CLSCompliant( false )]
4040
[assembly: NeutralResourcesLanguage( "en-US" )]

UpdateInstaller/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion( "0.6.2.1" )]
35-
[assembly: AssemblyFileVersion( "0.6.2.1" )]
34+
[assembly: AssemblyVersion( "0.6.2.2" )]
35+
[assembly: AssemblyFileVersion( "0.6.2.2" )]

UpdaterBuilder/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion( "0.6.2.1" )]
35-
[assembly: AssemblyFileVersion( "0.6.2.1" )]
34+
[assembly: AssemblyVersion( "0.6.2.2" )]
35+
[assembly: AssemblyFileVersion( "0.6.2.2" )]

fCraft/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion( "0.6.2.1" )]
37-
[assembly: AssemblyFileVersion( "0.6.2.1" )]
36+
[assembly: AssemblyVersion( "0.6.2.2" )]
37+
[assembly: AssemblyFileVersion( "0.6.2.2" )]
3838

3939
[assembly: CLSCompliant( false )]
4040
[assembly: NeutralResourcesLanguage( "en-US" )]

fCraft/System/Logger.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ public static class Logger {
3232
static readonly Queue<string> RecentMessages = new Queue<string>();
3333
const int MaxRecentMessages = 25;
3434

35+
public static string CurrentLogFileName {
36+
get {
37+
switch( SplittingType ) {
38+
case LogSplittingType.SplitBySession:
39+
return SessionStart + ".log";
40+
case LogSplittingType.SplitByDay:
41+
return DateTime.Now.ToString( ShortDateFormat ) + ".log"; // localized
42+
default:
43+
return DefaultLogFileName;
44+
}
45+
}
46+
}
47+
3548

3649
static Logger() {
3750
Enabled = true;
@@ -93,20 +106,8 @@ public static void Log( LogType type, [NotNull] string message ) {
93106
}
94107

95108
if( LogFileOptions[(int)type] ) {
96-
string actualLogFileName;
97-
switch( SplittingType ) {
98-
case LogSplittingType.SplitBySession:
99-
actualLogFileName = Path.Combine( Paths.LogPath, SessionStart + ".log" );
100-
break;
101-
case LogSplittingType.SplitByDay:
102-
actualLogFileName = Path.Combine( Paths.LogPath, DateTime.Now.ToString( ShortDateFormat ) + ".log" ); // localized
103-
break;
104-
default:
105-
actualLogFileName = Path.Combine( Paths.LogPath, DefaultLogFileName );
106-
break;
107-
}
108109
try {
109-
File.AppendAllText( actualLogFileName, line + Environment.NewLine );
110+
File.AppendAllText( Path.Combine( Paths.LogPath, CurrentLogFileName ), line + Environment.NewLine );
110111
} catch( Exception ex ) {
111112
string errorMessage = "Logger.Log: " + ex.Message;
112113
RaiseLoggedEvent( errorMessage,

fCraft/Utils/Updater.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ namespace fCraft {
1616
public static class Updater {
1717

1818
public static readonly ReleaseInfo CurrentRelease = new ReleaseInfo(
19-
621,
20-
1611,
19+
622,
20+
1612,
2121
new DateTime( 2012, 7, 5, 8, 30, 0, DateTimeKind.Utc ),
2222
"", "",
23-
ReleaseFlags.Feature | ReleaseFlags.Bugfix | ReleaseFlags.Optimized
23+
ReleaseFlags.Dev
2424
#if DEBUG
2525
| ReleaseFlags.Dev
2626
#endif

fCraftGUI/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion( "0.6.2.1" )]
35-
[assembly: AssemblyFileVersion( "0.6.2.1" )]
34+
[assembly: AssemblyVersion( "0.6.2.2" )]
35+
[assembly: AssemblyFileVersion( "0.6.2.2" )]

0 commit comments

Comments
 (0)