Skip to content

Commit 7dedb43

Browse files
committed
Session log path / file name changed, added to profile.
1 parent 5fd542f commit 7dedb43

15 files changed

Lines changed: 287 additions & 156 deletions

File tree

‎Source/NETworkManager.Localization/Resources/Strings.Designer.cs‎

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

‎Source/NETworkManager.Localization/Resources/Strings.resx‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2851,20 +2851,20 @@ URL: https://github.com/BornToBeRoot/NETworkManager/tree/master/Documentation</v
28512851
<data name="SettingsViewName_Window" xml:space="preserve">
28522852
<value>Window</value>
28532853
</data>
2854-
<data name="EnableSessionLog" xml:space="preserve">
2855-
<value>Enable session log</value>
2854+
<data name="EnableLog" xml:space="preserve">
2855+
<value>Enable log</value>
28562856
</data>
2857-
<data name="SessionLogFileName" xml:space="preserve">
2858-
<value>Session log file name</value>
2857+
<data name="LogFileName" xml:space="preserve">
2858+
<value>Log file name</value>
28592859
</data>
2860-
<data name="SessionLogPath" xml:space="preserve">
2861-
<value>Session log path</value>
2860+
<data name="LogPath" xml:space="preserve">
2861+
<value>Log path</value>
28622862
</data>
28632863
<data name="LogMode" xml:space="preserve">
28642864
<value>Log mode</value>
28652865
</data>
2866-
<data name="SessionLog" xml:space="preserve">
2867-
<value>Session log</value>
2866+
<data name="Log" xml:space="preserve">
2867+
<value>Log</value>
28682868
</data>
28692869
<data name="SSHLog" xml:space="preserve">
28702870
<value>SSH log</value>

‎Source/NETworkManager.Models/PuTTY/PuTTY.cs‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
namespace NETworkManager.Models.PuTTY
1+
using System;
2+
using System.IO;
3+
4+
namespace NETworkManager.Models.PuTTY
25
{
36
public partial class PuTTY
47
{
@@ -34,9 +37,24 @@ public static string BuildCommandLine(PuTTYSessionInfo profileInfo)
3437
if (!string.IsNullOrEmpty(profileInfo.Username))
3538
command += $" -l {profileInfo.Username}";
3639

37-
// Session log
38-
if (profileInfo.EnableSessionLog)
39-
command += $" -sessionlog {'"'}{ profileInfo.SessionLogFullName}{'"'}";
40+
// Log
41+
if (profileInfo.EnableLog)
42+
{
43+
switch(profileInfo.LogMode)
44+
{
45+
case LogMode.SessionLog:
46+
command += $" -sessionlog";
47+
break;
48+
case LogMode.SSHLog:
49+
command += $" -sshlog";
50+
break;
51+
case LogMode.SSHRawLog:
52+
command += $" -sshrawlog";
53+
break;
54+
}
55+
56+
command += $" {'"'}{ Environment.ExpandEnvironmentVariables(Path.Combine(profileInfo.LogPath, profileInfo.LogFileName))}{'"'}";
57+
}
4058

4159
// Additional commands
4260
if (!string.IsNullOrEmpty(profileInfo.AdditionalCommandLine))

‎Source/NETworkManager.Models/PuTTY/PuTTYSessionInfo.cs‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,22 @@ public class PuTTYSessionInfo
3838
/// <summary>
3939
/// Enables session log.
4040
/// </summary>
41-
public bool EnableSessionLog { get; set; }
41+
public bool EnableLog { get; set; }
4242

4343
/// <summary>
44-
/// Path and filename of the session log file (e.g. "C:\..\PuTTY.log").
44+
/// PuTTY log mode.
4545
/// </summary>
46-
public string SessionLogFullName { get; set; }
46+
public LogMode LogMode { get; set; }
47+
48+
/// <summary>
49+
/// Path to the PuTTY log files like "C:\temp".
50+
/// </summary>
51+
public string LogPath { get; set; }
52+
53+
/// <summary>
54+
/// Filename of the PuTTY log like "PuTTY.log".
55+
/// </summary>
56+
public string LogFileName { get; set; }
4757

4858
/// <summary>
4959
/// Additional command line argument. Everything putty can handle.

‎Source/NETworkManager.Profiles/Application/PuTTY.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using NETworkManager.Models.PuTTY;
22
using NETworkManager.Settings;
3-
using System.IO;
4-
using System;
53

64
namespace NETworkManager.Profiles.Application
75
{
@@ -16,8 +14,10 @@ public static PuTTYSessionInfo CreateSessionInfo(ProfileInfo profileInfo)
1614
PortOrBaud = profileInfo.PuTTY_OverridePortOrBaud ? profileInfo.PuTTY_PortOrBaud : Settings.Application.PuTTY.GetPortOrBaudByConnectionMode(profileInfo.PuTTY_ConnectionMode),
1715
Username = profileInfo.PuTTY_OverrideUsername ? profileInfo.PuTTY_Username : SettingsManager.Current.PuTTY_Username,
1816
Profile = profileInfo.PuTTY_OverrideProfile ? profileInfo.PuTTY_Profile : SettingsManager.Current.PuTTY_Profile,
19-
EnableSessionLog = profileInfo.PuTTY_OverrideEnableSessionLog ? profileInfo.PuTTY_EnableSessionLog : SettingsManager.Current.PuTTY_EnableSessionLog,
20-
SessionLogFullName = Environment.ExpandEnvironmentVariables(Path.Combine(SettingsManager.Current.PuTTY_SessionLogPath, profileInfo.PuTTY_OverrideSessionLogFileName ? profileInfo.PuTTY_SessionLogFileName : SettingsManager.Current.PuTTY_SessionLogFileName)),
17+
EnableLog = profileInfo.PuTTY_OverrideEnableLog ? profileInfo.PuTTY_EnableLog : SettingsManager.Current.PuTTY_EnableSessionLog,
18+
LogMode = profileInfo.PuTTY_OverrideLogMode ? profileInfo.PuTTY_LogMode : SettingsManager.Current.PuTTY_LogMode,
19+
LogPath = profileInfo.PuTTY_OverrideLogPath ? profileInfo.PuTTY_LogPath : SettingsManager.Current.PuTTY_LogPath,
20+
LogFileName = profileInfo.PuTTY_OverrideLogFileName ? profileInfo.PuTTY_LogFileName : SettingsManager.Current.PuTTY_LogFileName,
2121
AdditionalCommandLine = profileInfo.PuTTY_OverrideAdditionalCommandLine ? profileInfo.PuTTY_AdditionalCommandLine : SettingsManager.Current.PuTTY_AdditionalCommandLine
2222
};
2323

‎Source/NETworkManager.Profiles/ProfileInfo.cs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ public class ProfileInfo
124124
public string PuTTY_Username { get; set; }
125125
public bool PuTTY_OverrideProfile { get; set; }
126126
public string PuTTY_Profile { get; set; }
127-
public bool PuTTY_OverrideEnableSessionLog { get; set; }
128-
public bool PuTTY_EnableSessionLog { get; set; }
129-
public bool PuTTY_OverrideSessionLogMode { get; set; }
130-
public LogMode PuTTY_SessionLogMode { get; set; } = GlobalStaticConfiguration.PuTTY_SessionLogMode;
131-
public bool PuTTY_OverrideSessionLogFileName { get; set; }
132-
public string PuTTY_SessionLogFileName { get; set; } = GlobalStaticConfiguration.PuTTY_SessionLogFileName;
127+
public bool PuTTY_OverrideEnableLog { get; set; }
128+
public bool PuTTY_EnableLog { get; set; }
129+
public bool PuTTY_OverrideLogMode { get; set; }
130+
public LogMode PuTTY_LogMode { get; set; } = GlobalStaticConfiguration.PuTTY_LogMode;
131+
public bool PuTTY_OverrideLogPath { get; set; }
132+
public string PuTTY_LogPath { get; set; } = GlobalStaticConfiguration.PuTTY_LogPath;
133+
public bool PuTTY_OverrideLogFileName { get; set; }
134+
public string PuTTY_LogFileName { get; set; } = GlobalStaticConfiguration.PuTTY_LogFileName;
133135
public bool PuTTY_OverrideAdditionalCommandLine { get; set; }
134136
public string PuTTY_AdditionalCommandLine { get; set; }
135137

‎Source/NETworkManager.Settings/GlobalStaticConfiguration.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ public static class GlobalStaticConfiguration
118118

119119
// Application: PuTTY
120120
public static ConnectionMode PuTTY_DefaultConnectionMode => ConnectionMode.SSH;
121-
public static LogMode PuTTY_SessionLogMode => LogMode.SessionLog;
122-
public static string PuTTY_SessionLogPath => Path.Combine("%LocalAppData%", AssemblyManager.Current.Name, "PuTTY_LogFiles");
123-
public static string PuTTY_SessionLogFileName => "&H_&Y-&M-&D_&T.log";
121+
public static LogMode PuTTY_LogMode => LogMode.SessionLog;
122+
public static string PuTTY_LogPath => Path.Combine("%LocalAppData%", AssemblyManager.Current.Name, "PuTTY_LogFiles");
123+
public static string PuTTY_LogFileName => "&H_&Y-&M-&D_&T.log";
124124
public static int PuTTY_SSHPort => 22;
125125
public static string PuTTY_SerialLine => "COM1";
126126
public static int PuTTY_TelnetPort => 23;

‎Source/NETworkManager.Settings/SettingsInfo.cs‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,46 +2605,46 @@ public bool PuTTY_EnableSessionLog
26052605
}
26062606
}
26072607

2608-
private LogMode _puTTY_SessionLogMode = GlobalStaticConfiguration.PuTTY_SessionLogMode;
2609-
public LogMode PuTTY_SessionLogMode
2608+
private LogMode _puTTY_LogMode = GlobalStaticConfiguration.PuTTY_LogMode;
2609+
public LogMode PuTTY_LogMode
26102610
{
2611-
get => _puTTY_SessionLogMode;
2611+
get => _puTTY_LogMode;
26122612
set
26132613
{
2614-
if (value == _puTTY_SessionLogMode)
2614+
if (value == _puTTY_LogMode)
26152615
return;
26162616

2617-
_puTTY_SessionLogMode = value;
2617+
_puTTY_LogMode = value;
26182618
OnPropertyChanged();
26192619
SettingsChanged = true;
26202620
}
26212621
}
26222622

2623-
private string _puTTY_SessionLogPath = GlobalStaticConfiguration.PuTTY_SessionLogPath;
2624-
public string PuTTY_SessionLogPath
2623+
private string _puTTY_LogPath = GlobalStaticConfiguration.PuTTY_LogPath;
2624+
public string PuTTY_LogPath
26252625
{
2626-
get => _puTTY_SessionLogPath;
2626+
get => _puTTY_LogPath;
26272627
set
26282628
{
2629-
if (value == _puTTY_SessionLogPath)
2629+
if (value == _puTTY_LogPath)
26302630
return;
26312631

2632-
_puTTY_SessionLogPath = value;
2632+
_puTTY_LogPath = value;
26332633
OnPropertyChanged();
26342634
SettingsChanged = true;
26352635
}
26362636
}
26372637

2638-
private string _puTTY_SessionLogFileName = GlobalStaticConfiguration.PuTTY_SessionLogFileName;
2639-
public string PuTTY_SessionLogFileName
2638+
private string _puTTY_LogFileName = GlobalStaticConfiguration.PuTTY_LogFileName;
2639+
public string PuTTY_LogFileName
26402640
{
2641-
get => _puTTY_SessionLogFileName;
2641+
get => _puTTY_LogFileName;
26422642
set
26432643
{
2644-
if (value == _puTTY_SessionLogFileName)
2644+
if (value == _puTTY_LogFileName)
26452645
return;
26462646

2647-
_puTTY_SessionLogFileName = value;
2647+
_puTTY_LogFileName = value;
26482648
OnPropertyChanged();
26492649
SettingsChanged = true;
26502650
}

‎Source/NETworkManager/Controls/PuTTYControl.xaml.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
9696
WindowHost.Width = (int)ActualWidth;
9797

9898
Connect();
99+
99100
_initialized = true;
100101
}
101102

@@ -123,7 +124,7 @@ private async void Connect()
123124
IsConnecting = true;
124125

125126
// Create log path
126-
DirectoryCreator.CreateWithEnvironmentVariables(SettingsManager.Current.PuTTY_SessionLogPath);
127+
DirectoryCreator.CreateWithEnvironmentVariables(_sessionInfo.LogPath);
127128

128129
var info = new ProcessStartInfo
129130
{

‎Source/NETworkManager/ProfileDialogManager.cs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,14 @@ public static void AddProfile(ProfileViewModel instance)
267267
PuTTY_Username = instance.PuTTY_Username?.Trim(),
268268
PuTTY_OverrideProfile = instance.PuTTY_OverrideProfile,
269269
PuTTY_Profile = instance.PuTTY_Profile?.Trim(),
270-
PuTTY_OverrideEnableSessionLog = instance.PuTTY_OverrideEnableSessionLog,
271-
PuTTY_EnableSessionLog = instance.PuTTY_EnableSessionLog,
272-
PuTTY_OverrideSessionLogFileName = instance.PuTTY_OverrideSessionLogFileName,
273-
PuTTY_SessionLogFileName = instance.PuTTY_SessionLogFileName,
270+
PuTTY_OverrideEnableLog = instance.PuTTY_OverrideEnableLog,
271+
PuTTY_EnableLog = instance.PuTTY_EnableLog,
272+
PuTTY_OverrideLogMode = instance.PuTTY_OverrideLogMode,
273+
PuTTY_LogMode = instance.PuTTY_LogMode,
274+
PuTTY_OverrideLogPath = instance.PuTTY_OverrideLogPath,
275+
PuTTY_LogPath = instance.PuTTY_LogPath,
276+
PuTTY_OverrideLogFileName = instance.PuTTY_OverrideLogFileName,
277+
PuTTY_LogFileName = instance.PuTTY_LogFileName,
274278
PuTTY_OverrideAdditionalCommandLine = instance.PuTTY_OverrideAdditionalCommandLine,
275279
PuTTY_AdditionalCommandLine = instance.PuTTY_AdditionalCommandLine?.Trim(),
276280

0 commit comments

Comments
 (0)