mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-16 13:14:49 +00:00
Merged in hotfix/debug-errorlog (pull request #1)
Hotfix/debug errorlog
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -212,55 +212,28 @@ namespace PepperDash.Core
|
|||||||
kauth.AuthenticationPrompt += new EventHandler<AuthenticationPromptEventArgs>(kauth_AuthenticationPrompt);
|
kauth.AuthenticationPrompt += new EventHandler<AuthenticationPromptEventArgs>(kauth_AuthenticationPrompt);
|
||||||
PasswordAuthenticationMethod pauth = new PasswordAuthenticationMethod(Username, Password);
|
PasswordAuthenticationMethod pauth = new PasswordAuthenticationMethod(Username, Password);
|
||||||
|
|
||||||
// Make a new client if we need it or things have changed
|
|
||||||
//if (Client == null || PropertiesHaveChanged())
|
|
||||||
//{
|
|
||||||
if (Client != null)
|
if (Client != null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Cleaning up disconnected client");
|
Debug.Console(1, this, "Cleaning up disconnected client");
|
||||||
Client.ErrorOccurred -= Client_ErrorOccurred;
|
Client.ErrorOccurred -= Client_ErrorOccurred;
|
||||||
KillStream();
|
KillStream();
|
||||||
|
|
||||||
//if (TheStream != null)
|
|
||||||
//{
|
|
||||||
// TheStream.DataReceived -= Stream_DataReceived;
|
|
||||||
// TheStream.ErrorOccurred -= TheStream_ErrorOccurred;
|
|
||||||
//}
|
|
||||||
//TheStream = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(1, this, "Creating new SshClient");
|
Debug.Console(1, this, "Creating new SshClient");
|
||||||
ConnectionInfo connectionInfo = new ConnectionInfo(Hostname, Port, Username, pauth, kauth);
|
ConnectionInfo connectionInfo = new ConnectionInfo(Hostname, Port, Username, pauth, kauth);
|
||||||
Client = new SshClient(connectionInfo);
|
Client = new SshClient(connectionInfo);
|
||||||
Client.ErrorOccurred += Client_ErrorOccurred;
|
Client.ErrorOccurred += Client_ErrorOccurred;
|
||||||
//}
|
|
||||||
//PreviousHostname = Hostname;
|
|
||||||
//PreviousPassword = Password;
|
|
||||||
//PreviousPort = Port;
|
|
||||||
//PreviousUsername = Username;
|
|
||||||
|
|
||||||
//You can do it!
|
//You can do it!
|
||||||
ClientStatus = SocketStatus.SOCKET_STATUS_WAITING;
|
ClientStatus = SocketStatus.SOCKET_STATUS_WAITING;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Client.Connect();
|
Client.Connect();
|
||||||
|
|
||||||
// Have to assume client is connected cause Client.IsConnected is busted in some cases
|
|
||||||
// All other conditions *should* error out...
|
|
||||||
//if (Client.IsConnected)
|
|
||||||
//{
|
|
||||||
//Client.KeepAliveInterval = TimeSpan.FromSeconds(2);
|
|
||||||
//Client.SendKeepAlive();
|
|
||||||
TheStream = Client.CreateShellStream("PDTShell", 100, 80, 100, 200, 65534);
|
TheStream = Client.CreateShellStream("PDTShell", 100, 80, 100, 200, 65534);
|
||||||
TheStream.DataReceived += Stream_DataReceived;
|
TheStream.DataReceived += Stream_DataReceived;
|
||||||
//TheStream.ErrorOccurred += TheStream_ErrorOccurred;
|
//TheStream.ErrorOccurred += TheStream_ErrorOccurred;
|
||||||
Debug.Console(1, this, "Connected");
|
Debug.Console(1, this, "Connected");
|
||||||
ClientStatus = SocketStatus.SOCKET_STATUS_CONNECTED;
|
ClientStatus = SocketStatus.SOCKET_STATUS_CONNECTED;
|
||||||
//PreviousHostname = Hostname;
|
|
||||||
//PreviousPassword = Password;
|
|
||||||
//PreviousPort = Port;
|
|
||||||
//PreviousUsername = Username;
|
|
||||||
//}
|
|
||||||
return; // Success will not pass here
|
return; // Success will not pass here
|
||||||
}
|
}
|
||||||
catch (SshConnectionException e)
|
catch (SshConnectionException e)
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Appends a device Key to the beginning of a message
|
/// Logs to Console when at-level, and all messages to error log, including device key
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Console(uint level, IKeyed dev, string format, params object[] items)
|
public static void Console(uint level, IKeyed dev, string format, params object[] items)
|
||||||
{
|
{
|
||||||
@@ -245,22 +245,25 @@ namespace PepperDash.Core
|
|||||||
public static void Console(uint level, IKeyed dev, ErrorLogLevel errorLogLevel,
|
public static void Console(uint level, IKeyed dev, ErrorLogLevel errorLogLevel,
|
||||||
string format, params object[] items)
|
string format, params object[] items)
|
||||||
{
|
{
|
||||||
|
var str = string.Format("[{0}] {1}", dev.Key, string.Format(format, items));
|
||||||
|
LogError(errorLogLevel, str);
|
||||||
if (Level >= level)
|
if (Level >= level)
|
||||||
{
|
{
|
||||||
var str = string.Format("[{0}] {1}", dev.Key, string.Format(format, items));
|
|
||||||
Console(level, str);
|
Console(level, str);
|
||||||
LogError(errorLogLevel, str);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logs to Console when at-level, and all messages to error log
|
||||||
|
/// </summary>
|
||||||
public static void Console(uint level, ErrorLogLevel errorLogLevel,
|
public static void Console(uint level, ErrorLogLevel errorLogLevel,
|
||||||
string format, params object[] items)
|
string format, params object[] items)
|
||||||
{
|
{
|
||||||
|
var str = string.Format(format, items);
|
||||||
|
LogError(errorLogLevel, str);
|
||||||
if (Level >= level)
|
if (Level >= level)
|
||||||
{
|
{
|
||||||
var str = string.Format(format, items);
|
|
||||||
Console(level, str);
|
Console(level, str);
|
||||||
LogError(errorLogLevel, str);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("Pepperdash_Core")]
|
[assembly: AssemblyProduct("Pepperdash_Core")]
|
||||||
[assembly: AssemblyCopyright("Copyright © PepperDash 2016")]
|
[assembly: AssemblyCopyright("Copyright © PepperDash 2016")]
|
||||||
[assembly: AssemblyVersion("1.0.7.*")]
|
[assembly: AssemblyVersion("1.0.8.*")]
|
||||||
|
|||||||
Reference in New Issue
Block a user