-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06aeea8
commit e59979e
Showing
14 changed files
with
1,041 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" /> | ||
</startup> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("SSH-FileGrabber")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("SSH-FileGrabber")] | ||
[assembly: AssemblyCopyright("Copyright © 2024")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
[assembly: ComVisible(false)] | ||
|
||
[assembly: Guid("305d3d7e-daac-4bc9-81f0-51c2bca3fbed")] | ||
|
||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] | ||
[assembly: AssemblyInformationalVersion("1.0 dev")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
<security> | ||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<!-- UAC-Manifestoptionen | ||
Wenn Sie die Ebene der Benutzerkontensteuerung für Windows ändern möchten, ersetzen Sie den | ||
Knoten "requestedExecutionLevel" wie folgt. | ||
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> | ||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | ||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> | ||
Durch Angabe des Elements "requestedExecutionLevel" wird die Datei- und Registrierungsvirtualisierung deaktiviert. | ||
Entfernen Sie dieses Element, wenn diese Virtualisierung aus Gründen der Abwärtskompatibilität | ||
für die Anwendung erforderlich ist. | ||
--> | ||
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> | ||
</requestedPrivileges> | ||
</security> | ||
</trustInfo> | ||
|
||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | ||
<application> | ||
<!-- Eine Liste der Windows-Versionen, unter denen diese Anwendung getestet | ||
und für die sie entwickelt wurde. Wenn Sie die Auskommentierung der entsprechenden Elemente aufheben, | ||
wird von Windows automatisch die kompatibelste Umgebung ausgewählt. --> | ||
|
||
<!-- Windows Vista --> | ||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />--> | ||
|
||
<!-- Windows 7 --> | ||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />--> | ||
|
||
<!-- Windows 8 --> | ||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />--> | ||
|
||
<!-- Windows 8.1 --> | ||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />--> | ||
|
||
<!-- Windows 10 --> | ||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />--> | ||
|
||
</application> | ||
</compatibility> | ||
|
||
<!-- Gibt an, dass die Anwendung mit DPI-Werten kompatibel ist und von Windows nicht automatisch auf höhere | ||
DPI-Werte skaliert wird. WPF-Anwendungen (Windows Presentation Foundation) sind automatisch mit DPI-Werten kompatibel, eine Aktivierung | ||
ist nicht erforderlich. Für Windows Forms-Anwendungen für .NET Framework 4.6, die diese Einstellung aktivieren, muss | ||
auch die Einstellung "'EnableWindowsFormsHighDpiAutoResizing" in der Datei "app.config" auf TRUE festgelegt werden. | ||
Hierdurch können für die Anwendung lange Pfade verwendet werden. Weitere Informationen finden Sie unter https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation.--> | ||
<!-- | ||
<application xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<windowsSettings> | ||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> | ||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware> | ||
</windowsSettings> | ||
</application> | ||
--> | ||
|
||
<!-- Designs für allgemeine Windows-Steuerelemente und -Dialogfelder (Windows XP und höher) aktivieren --> | ||
<!-- | ||
<dependency> | ||
<dependentAssembly> | ||
<assemblyIdentity | ||
type="win32" | ||
name="Microsoft.Windows.Common-Controls" | ||
version="6.0.0.0" | ||
processorArchitecture="*" | ||
publicKeyToken="6595b64144ccf1df" | ||
language="*" | ||
/> | ||
</dependentAssembly> | ||
</dependency> | ||
--> | ||
|
||
</assembly> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net481" /> | ||
<package id="SSH.NET" version="2024.1.0" targetFramework="net481" /> | ||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net481" /> | ||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net481" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
using System; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
#pragma warning disable CS8618 | ||
#pragma warning disable CS8625 | ||
|
||
namespace BSS.Logging | ||
{ | ||
internal static class Log | ||
{ | ||
private static Boolean _isInitialized = false; | ||
private static String _assemblyPath; | ||
private static readonly Object _fileLock = new(); | ||
|
||
internal static void Initialize(String assemblyPath = null) | ||
{ | ||
if (_isInitialized) return; | ||
|
||
_assemblyPath = assemblyPath ?? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); | ||
|
||
if (Directory.Exists($"{_assemblyPath}\\logs")) | ||
{ | ||
DateTime now = DateTime.Now; | ||
|
||
if (File.Exists($"{_assemblyPath}\\logs\\{now:dd.MM.yyyy}.txt")) | ||
{ | ||
using (StreamWriter streamWriter = new($"{_assemblyPath}\\logs\\{now:dd.MM.yyyy}.txt", true, Encoding.UTF8)) | ||
{ | ||
streamWriter.WriteLine(); | ||
} | ||
} | ||
} | ||
|
||
_isInitialized = true; | ||
} | ||
|
||
// ####################################################################################### | ||
|
||
internal static void FastLog(String message, LogSeverity severity, String source) | ||
{ | ||
DateTime now = DateTime.Now; | ||
|
||
LogMessage logMessage; | ||
logMessage.Message = message; | ||
logMessage.Severity = severity; | ||
logMessage.Source = source; | ||
|
||
WriteFile(ref logMessage, ref now); | ||
} | ||
|
||
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
|
||
internal static void WriteFile(ref readonly LogMessage formattedLogMessage, ref readonly DateTime timeStamp) | ||
{ | ||
if (!_isInitialized) throw new MethodAccessException("Logging class not initialized"); | ||
|
||
if (!Directory.Exists($"{_assemblyPath}\\logs")) | ||
{ | ||
Directory.CreateDirectory($"{_assemblyPath}\\logs"); | ||
} | ||
|
||
String logLine = ""; | ||
UInt16 lineLength = 27; | ||
|
||
logLine += $"[{timeStamp:dd.MM.yyyy HH:mm:ss}] ["; | ||
|
||
switch (formattedLogMessage.Severity) | ||
{ | ||
case LogSeverity.Info: | ||
lineLength += 4; | ||
logLine += "Info"; | ||
break; | ||
case LogSeverity.Debug: | ||
lineLength += 5; | ||
logLine += "Debug"; | ||
break; | ||
case LogSeverity.Warning: | ||
lineLength += 7; | ||
logLine += "Warning"; | ||
break; | ||
case LogSeverity.Verbose: | ||
lineLength += 7; | ||
logLine += "Verbose"; | ||
break; | ||
case LogSeverity.Error: | ||
lineLength += 5; | ||
logLine += "Error"; | ||
break; | ||
case LogSeverity.Critical: | ||
lineLength += 8; | ||
logLine += "Critical"; | ||
break; | ||
case LogSeverity.Alert: | ||
lineLength += 5; | ||
logLine += "Alert"; | ||
break; | ||
} | ||
|
||
logLine += $"]-[{formattedLogMessage.Source}]"; | ||
|
||
lineLength += (UInt16)formattedLogMessage.Source.Length; | ||
|
||
if (lineLength < 52) | ||
{ | ||
for (UInt16 i = lineLength; i < 52; ++i) | ||
{ | ||
logLine += " "; | ||
} | ||
} | ||
else | ||
{ | ||
logLine += " "; | ||
} | ||
|
||
logLine += formattedLogMessage.Message; | ||
|
||
// | ||
|
||
try | ||
{ | ||
lock (_fileLock) | ||
{ | ||
xDebug.WriteLine(logLine); | ||
|
||
using (StreamWriter streamWriter = new($"{_assemblyPath}\\logs\\{timeStamp:dd.MM.yyyy}.txt", true, Encoding.UTF8)) | ||
{ | ||
streamWriter.WriteLine(logLine); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw new FieldAccessException($"Unable to write log file to:\n{_assemblyPath}\\logs\\{timeStamp:dd.MM.yyyy}.txt\n\nError: {ex.Message}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
|
||
namespace BSS.Logging | ||
{ | ||
internal ref struct LogMessage | ||
{ | ||
internal LogMessage(String message, LogSeverity severity, String source) | ||
{ | ||
Message = message; | ||
Severity = severity; | ||
Source = source; | ||
} | ||
|
||
internal LogSeverity Severity; | ||
|
||
internal String Source; | ||
internal String Message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace BSS.Logging | ||
{ | ||
internal enum LogSeverity | ||
{ | ||
///<summary>Logs that contain the most severe level of error. This type of error indicates that immediate attention may be required.</summary> | ||
Critical = 0, | ||
///<summary>Logs that highlight when the flow of execution is stopped due to a failure.</summary> | ||
Error = 1, | ||
///<summary>Logs that highlight an abnormal activity in the flow of execution.</summary> | ||
Warning = 2, | ||
///<summary>Logs that track the general flow of the application.</summary> | ||
Info = 3, | ||
///<summary>Logs that are used for interactive investigation during development.</summary> | ||
Verbose = 4, | ||
///<summary>Logs that contain the most detailed messages.</summary> | ||
Debug = 5, | ||
///<summary>Logs that highlight an abnormal activity in the flow of execution. This type of error indicates that immediate attention may be required.</summary> | ||
Alert = 6, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace BSS.Logging | ||
{ | ||
internal static class xDebug | ||
{ | ||
[DllImport("kernel32.dll")] | ||
static extern Boolean AllocConsole(); | ||
|
||
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
[Conditional("DEBUG")] | ||
internal static void Initialize() => AllocConsole(); | ||
|
||
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
[Conditional("DEBUG")] | ||
internal static void Write(Object input) => Console.Write(input); | ||
[Conditional("DEBUG")] | ||
internal static void WriteLine(Object input) => Console.WriteLine(input); | ||
} | ||
} |
Oops, something went wrong.