Updated README + some minor code changes

This commit is contained in:
Stone-Red-Code
2021-04-14 19:22:52 +02:00
parent 9c307d9852
commit 466c32cfb3
25 changed files with 275 additions and 23 deletions
Binary file not shown.
+51 -2
View File
@@ -1,6 +1,6 @@
# Stone_Red-C-Sharp-Utilities
> Adds useful C# methods.
> Provides useful C# methods.
## Install
@@ -64,7 +64,7 @@ https://www.nuget.org/packages/Stone_Red-C-Sharp-Utilities
-------------
```
### Stone_Red_Utilities.ColorConsole
### Stone_Red_Utilities.ConsoleExtentions
#### Methods:
* Write
* Description: Writes the text representation of the specified object to the standard output stream.
@@ -187,3 +187,52 @@ https://www.nuget.org/packages/Stone_Red-C-Sharp-Utilities
```
True
```
### Stone_Red_Utilities.Logging
#### Constructors:
* Logger
* Initializes the logger with the default format.
* Parameters: `LogTarget logTarg`, `string defaultFormat`
* Example usage:
```cs
Logger logger = new Logger(LogTarget.Console, "{<dateTime>:HH:mm:ss} | {<level>,-7} | {<source>,-15} | {<message>}");
```
* Logger
* Initializes the logger with the default format and a file path.
* Parameters: `LogTarget logTarg`, `string file`, `string defaultFormat`
* Example usage:
```cs
Logger logger = new Logger(LogTarget.ConsoleAndFile, "events.log", "{<dateTime>:HH:mm:ss} | {<level>,-7} | {<source>,-15} | {<message>}");
```
#### Methods:
* Log
* Description: Log the message to the specified output
* Parameters: `string message`, `string source`, `LogSeverity logSeverity`
* Example usage:
```cs
logger.Log("something happend", "Update manager", LogSeverity.Error);
```
* Output (Depends on the specified log format):
```
19:15:14 | Error | Update manager | something happend
```
* LogIf
* Description: Log the message to the specified output if the condition is met
* Parameters: `bool condition`, `string message`, `string source`, `LogSeverity logSeverity`
* Example usage:
```cs
logger.Log(IsValid(),"something is invalid", "Setup", LogSeverity.Error);
```
* Output (Depends on the specified log format):
```
19:15:14 | Error | Update manager | something happend
```
* ClearLogFile
* Description: Clears the log file
* Example usage:
```cs
logger.ClearLogFile();
```
* Output (Depends on the specified log format):
```
19:15:14 | Error | Update manager | something happend
```
+6 -6
View File
@@ -97,7 +97,7 @@ namespace Stone_Red_Utilities.Logging
public string FileLogFormat { get; set; }
/// <summary>
/// Initializes the logger with the default format
/// Initializes the logger with the default format and a file path
/// </summary>
/// <param name="defaultFormat"></param>
/// <param name="logTarg"></param>
@@ -105,7 +105,7 @@ namespace Stone_Red_Utilities.Logging
public Logger(LogTarget logTarg = LogTarget.Console, string file = null, string defaultFormat = "{<dateTime>:HH:mm:ss} | {<level>,-7} | {<source>,-15} | {<message>}")
{
if (logTarg == LogTarget.ConsoleAndFile || logTarg == LogTarget.DebugAndFile || logTarg == LogTarget.File || logTarg == LogTarget.All)
logPath = file ?? throw new ArgumentNullException($"file can't be null!");
logPath = file ?? throw new ArgumentNullException(nameof(file), $"file can't be null!");
logTarget = logTarg;
ConsoleLogFormat = defaultFormat;
@@ -121,7 +121,7 @@ namespace Stone_Red_Utilities.Logging
public Logger(LogTarget logTarg = LogTarget.Console, string defaultFormat = "{<dateTime:HH:mm:ss>} | {<level>,-7} | {<source>,-15} | {<message>}")
{
if (logTarg == LogTarget.ConsoleAndFile || logTarg == LogTarget.DebugAndFile || logTarg == LogTarget.File || logTarg == LogTarget.All)
throw new ArgumentNullException($"file can't be null!");
throw new ArgumentNullException("file", $"file can't be null!");
logTarget = logTarg;
ConsoleLogFormat = defaultFormat;
@@ -144,7 +144,7 @@ namespace Stone_Red_Utilities.Logging
}
/// <summary>
/// Log the message to the specified output when the condition is met
/// Log the message to the specified output if the condition is met
/// </summary>
/// <param name="condition"></param>
/// <param name="message"></param>
@@ -160,7 +160,7 @@ namespace Stone_Red_Utilities.Logging
}
/// <summary>
/// Clears log file
/// Clears the log file
/// </summary>
public void ClearLogFile()
{
@@ -221,7 +221,7 @@ namespace Stone_Red_Utilities.Logging
};
}
private string GetFormattedString(string format, LogSeverity logSeverity, string source, string message, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
private string GetFormattedString(string format, LogSeverity logSeverity, string source, string message, string memberName, string sourceFilePath, int sourceLineNumber)
{
format = format
.Replace("<dateTime>", "0")
@@ -14,7 +14,7 @@
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<AssemblyVersion>1.0.0.2</AssemblyVersion>
<FileVersion>1.0.0.2</FileVersion>
<Version>1.0.0.2</Version>
<Version>1.0.1.0</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -96,6 +96,13 @@
<param name="value"></param>
<param name="color"></param>
</member>
<member name="M:Stone_Red_Utilities.ConsoleExtentions.ConsoleExt.Pause(System.Boolean,System.String)">
<summary>
Suspends execution until the user presses a key
</summary>
<param name="enterKeyOnly"></param>
<param name="customMessage"></param>
</member>
<member name="T:Stone_Red_Utilities.Logging.LogTarget">
<summary>
Specifies the severity of the log target.
@@ -183,7 +190,7 @@
</member>
<member name="M:Stone_Red_Utilities.Logging.Logger.#ctor(Stone_Red_Utilities.Logging.LogTarget,System.String,System.String)">
<summary>
Initializes the logger with the default format
Initializes the logger with the default format and a file path
</summary>
<param name="defaultFormat"></param>
<param name="logTarg"></param>
@@ -209,7 +216,7 @@
</member>
<member name="M:Stone_Red_Utilities.Logging.Logger.LogIf(System.Boolean,System.String,System.String,Stone_Red_Utilities.Logging.LogSeverity,System.String,System.String,System.Int32)">
<summary>
Log the message to the specified output when the condition is met
Log the message to the specified output if the condition is met
</summary>
<param name="condition"></param>
<param name="message"></param>
@@ -221,7 +228,7 @@
</member>
<member name="M:Stone_Red_Utilities.Logging.Logger.ClearLogFile">
<summary>
Clears log file
Clears the log file
</summary>
</member>
<member name="T:Stone_Red_Utilities.StringExtentions.StringExt">
@@ -7,7 +7,7 @@
"targets": {
".NETStandard,Version=v2.1": {},
".NETStandard,Version=v2.1/": {
"Stone_Red-C-Sharp-Utilities/1.0.0.2": {
"Stone_Red-C-Sharp-Utilities/1.0.1.0": {
"runtime": {
"Stone_Red-C-Sharp-Utilities.dll": {}
}
@@ -15,7 +15,7 @@
}
},
"libraries": {
"Stone_Red-C-Sharp-Utilities/1.0.0.2": {
"Stone_Red-C-Sharp-Utilities/1.0.1.0": {
"type": "project",
"serviceable": false,
"sha512": ""
@@ -77,25 +77,160 @@
<param name="bol"></param>
<param name="input"></param>
</member>
<member name="T:Stone_Red_Utilities.ColorConsole.ConsoleExt">
<member name="T:Stone_Red_Utilities.ConsoleExtentions.ConsoleExt">
<summary>
Console Extentions
</summary>
</member>
<member name="M:Stone_Red_Utilities.ColorConsole.ConsoleExt.Write(System.Object,System.ConsoleColor)">
<member name="M:Stone_Red_Utilities.ConsoleExtentions.ConsoleExt.Write(System.Object,System.ConsoleColor)">
<summary>
Writes the text representation of the specified object to the standard output stream.
</summary>
<param name="value"></param>
<param name="color"></param>
</member>
<member name="M:Stone_Red_Utilities.ColorConsole.ConsoleExt.WriteLine(System.Object,System.ConsoleColor)">
<member name="M:Stone_Red_Utilities.ConsoleExtentions.ConsoleExt.WriteLine(System.Object,System.ConsoleColor)">
<summary>
Writes the text representation of the specified object, followed by the current line terminator, to the standard output stream.
</summary>
<param name="value"></param>
<param name="color"></param>
</member>
<member name="M:Stone_Red_Utilities.ConsoleExtentions.ConsoleExt.Pause(System.Boolean,System.String)">
<summary>
Suspends execution until the user presses a key
</summary>
<param name="enterKeyOnly"></param>
<param name="customMessage"></param>
</member>
<member name="T:Stone_Red_Utilities.Logging.LogTarget">
<summary>
Specifies the severity of the log target.
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogTarget.Console">
<summary>
Writes log to console
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogTarget.DebugConsole">
<summary>
Writes log to debug console
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogTarget.File">
<summary>
Writes log to file
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogTarget.ConsoleAndFile">
<summary>
Writes log to console and file
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogTarget.DebugAndFile">
<summary>
Writes log to debug console and file
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogTarget.All">
<summary>
Writes log to console debug console and file
</summary>
</member>
<member name="T:Stone_Red_Utilities.Logging.LogSeverity">
<summary>
Specifies the severity of the log message.
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogSeverity.Debug">
<summary>
Logs that contain the most detailed messages.
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogSeverity.Info">
<summary>
Logs that track the general flow of the application.
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogSeverity.Warning">
<summary>
Logs that highlight an abnormal activity in the flow of execution.
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogSeverity.Error">
<summary>
Logs that highlight when the flow of execution is stopped due to a failure.
</summary>
</member>
<member name="F:Stone_Red_Utilities.Logging.LogSeverity.Fatal">
<summary>
Logs that contain the most severe level of error. This type of error indicate that immediate attention may be required.
</summary>
</member>
<member name="T:Stone_Red_Utilities.Logging.Logger">
<summary>
Class used for logging
</summary>
</member>
<member name="P:Stone_Red_Utilities.Logging.Logger.ConsoleLogFormat">
<summary>
Format that is used when logging to the console
</summary>
</member>
<member name="P:Stone_Red_Utilities.Logging.Logger.DebugConsoleLogFormat">
<summary>
Format that is used when logging to the debug console
</summary>
</member>
<member name="P:Stone_Red_Utilities.Logging.Logger.FileLogFormat">
<summary>
Format that is used when logging to a file
</summary>
</member>
<member name="M:Stone_Red_Utilities.Logging.Logger.#ctor(Stone_Red_Utilities.Logging.LogTarget,System.String,System.String)">
<summary>
Initializes the logger with the default format and a file path
</summary>
<param name="defaultFormat"></param>
<param name="logTarg"></param>
<param name="file"></param>
</member>
<member name="M:Stone_Red_Utilities.Logging.Logger.#ctor(Stone_Red_Utilities.Logging.LogTarget,System.String)">
<summary>
Initializes the logger with the default format
</summary>
<param name="defaultFormat"></param>
<param name="logTarg"></param>
</member>
<member name="M:Stone_Red_Utilities.Logging.Logger.Log(System.String,System.String,Stone_Red_Utilities.Logging.LogSeverity,System.String,System.String,System.Int32)">
<summary>
Log the message to the specified output
</summary>
<param name="message"></param>
<param name="source"></param>
<param name="logSeverity"></param>
<param name="memberName"></param>
<param name="sourceFilePath"></param>
<param name="sourceLineNumber"></param>
</member>
<member name="M:Stone_Red_Utilities.Logging.Logger.LogIf(System.Boolean,System.String,System.String,Stone_Red_Utilities.Logging.LogSeverity,System.String,System.String,System.Int32)">
<summary>
Log the message to the specified output if the condition is met
</summary>
<param name="condition"></param>
<param name="message"></param>
<param name="source"></param>
<param name="logSeverity"></param>
<param name="memberName"></param>
<param name="sourceFilePath"></param>
<param name="sourceLineNumber"></param>
</member>
<member name="M:Stone_Red_Utilities.Logging.Logger.ClearLogFile">
<summary>
Clears the log file
</summary>
</member>
<member name="T:Stone_Red_Utilities.StringExtentions.StringExt">
<summary>
<see cref="T:System.String"/> Extentions
@@ -133,5 +268,22 @@
<param name="allowSpaces"></param>
<returns></returns>
</member>
<member name="M:Stone_Red_Utilities.StringExtentions.StringExt.Truncate(System.String,System.Int32)">
<summary>
Truncates a string to the specified length.
</summary>
<param name="str"></param>
<param name="length"></param>
<returns></returns>
</member>
<member name="M:Stone_Red_Utilities.StringExtentions.StringExt.Truncate(System.String,System.Int32,System.Boolean)">
<summary>
Truncates a string to the specified length.
</summary>
<param name="str"></param>
<param name="length"></param>
<param name="ellipsis"></param>
<returns></returns>
</member>
</members>
</doc>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Stone_Red-C-Sharp-Utilities</id>
<version>1.0.0.3</version>
<authors>Stone_Red</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="file">LICENSE</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
<description>Adds useful extentions.</description>
<tags>Console, Table, Print</tags>
<repository url="https://github.com/Stone-Red-Code/Stone_Red-C-Sharp-Utilities" />
<dependencies>
<group targetFramework=".NETStandard2.1" />
</dependencies>
</metadata>
<files>
<file src="C:\Users\David\Google Drive\Programmieren\Stone_Red-C-Sharp-Utilities\Stone_Red-C-Sharp-Utilities\bin\Release\netstandard2.1\Stone_Red-C-Sharp-Utilities.dll" target="lib\netstandard2.1\Stone_Red-C-Sharp-Utilities.dll" />
<file src="C:\Users\David\Google Drive\Programmieren\Stone_Red-C-Sharp-Utilities\Stone_Red-C-Sharp-Utilities\bin\Release\netstandard2.1\Stone_Red-C-Sharp-Utilities.xml" target="lib\netstandard2.1\Stone_Red-C-Sharp-Utilities.xml" />
<file src="C:\Users\David\Google Drive\Programmieren\Stone_Red-C-Sharp-Utilities\LICENSE" target="LICENSE" />
</files>
</package>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Stone_Red-C-Sharp-Utilities</id>
<version>1.0.1</version>
<authors>Stone_Red</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="file">LICENSE</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
<description>Adds useful extentions.</description>
<tags>Console, Table, Print</tags>
<repository url="https://github.com/Stone-Red-Code/Stone_Red-C-Sharp-Utilities" />
<dependencies>
<group targetFramework=".NETStandard2.1" />
</dependencies>
</metadata>
<files>
<file src="C:\Users\David\Google Drive\Programmieren\Stone_Red-C-Sharp-Utilities\Stone_Red-C-Sharp-Utilities\bin\Release\netstandard2.1\Stone_Red-C-Sharp-Utilities.dll" target="lib\netstandard2.1\Stone_Red-C-Sharp-Utilities.dll" />
<file src="C:\Users\David\Google Drive\Programmieren\Stone_Red-C-Sharp-Utilities\Stone_Red-C-Sharp-Utilities\bin\Release\netstandard2.1\Stone_Red-C-Sharp-Utilities.xml" target="lib\netstandard2.1\Stone_Red-C-Sharp-Utilities.xml" />
<file src="C:\Users\David\Google Drive\Programmieren\Stone_Red-C-Sharp-Utilities\LICENSE" target="LICENSE" />
</files>
</package>
@@ -15,7 +15,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("Adds useful extentions.")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.2")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0.2")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.1.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Stone_Red-C-Sharp-Utilities")]
[assembly: System.Reflection.AssemblyTitleAttribute("Stone_Red-C-Sharp-Utilities")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.2")]
@@ -1 +1 @@
4add0698c50aff5e6bd57f5b02d6f14125a759e5
86ed32e371a4832ff8ffcde04e090abd3861fffd
@@ -1 +1 @@
a57cbf8e3143b81e8c898c1738148a8800dbe5ce
ab7c68485a41e4caec8918d8132b9a5c789193c3
@@ -5,7 +5,7 @@
},
"projects": {
"C:\\Users\\David\\Google Drive\\Programmieren\\Stone_Red-C-Sharp-Utilities\\Stone_Red-C-Sharp-Utilities\\Stone_Red-C-Sharp-Utilities.csproj": {
"version": "1.0.0.2",
"version": "1.0.1",
"restore": {
"projectUniqueName": "C:\\Users\\David\\Google Drive\\Programmieren\\Stone_Red-C-Sharp-Utilities\\Stone_Red-C-Sharp-Utilities\\Stone_Red-C-Sharp-Utilities.csproj",
"projectName": "Stone_Red-C-Sharp-Utilities",
@@ -12,7 +12,7 @@
"C:\\Microsoft\\Xamarin\\NuGet\\": {}
},
"project": {
"version": "1.0.0.2",
"version": "1.0.1",
"restore": {
"projectUniqueName": "C:\\Users\\David\\Google Drive\\Programmieren\\Stone_Red-C-Sharp-Utilities\\Stone_Red-C-Sharp-Utilities\\Stone_Red-C-Sharp-Utilities.csproj",
"projectName": "Stone_Red-C-Sharp-Utilities",
@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "aWSVR7De4Q2VY3O6G2D1iAjpBH8farjDoaC5cvp5irFy5kocS3MdyJjSHdKZ0zSh3PnZ9Aj3Gdvrb1If7qdwSg==",
"dgSpecHash": "9bUdOQXkoJVmBHKtXL8WIV2wGOGQ2ZUNAipYzs4vkTUUx7it6qWwjRlEnfdvkceTSY3j3kyImDuhrb0sCF5omw==",
"success": true,
"projectFilePath": "C:\\Users\\David\\Google Drive\\Programmieren\\Stone_Red-C-Sharp-Utilities\\Stone_Red-C-Sharp-Utilities\\Stone_Red-C-Sharp-Utilities.csproj",
"expectedPackageFiles": [],