Pyther.Core
0.1.4
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Pyther.Core --version 0.1.4
NuGet\Install-Package Pyther.Core -Version 0.1.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pyther.Core" Version="0.1.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pyther.Core --version 0.1.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Pyther.Core, 0.1.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Pyther.Core as a Cake Addin #addin nuget:?package=Pyther.Core&version=0.1.4 // Install Pyther.Core as a Cake Tool #tool nuget:?package=Pyther.Core&version=0.1.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Pyther.Core
Library that provides logging functionality and extensions methods for strings and collections.
Logging
include namespace
using Pyther.Core.Logging;
add two example loggers
// a) Register a new console logger (with options)
Log.Register(new ConsoleLogger()
{
MinLevel = LogLevel.Warning // log Warning Level and above
});
// b) Register a new file logger (with options)
Log.Register(new FileLogger("path/to/file.log")
{
AppendMode = true, // append to exisiting file
UseTimestamp = true, // log timestamps
MinLevel = LogLevel.Debug, // log Debug Level and above
Lock = true // make thread safe
});
log something
// Errors should inform about critical problems that can't be resolved by the system.
Log.Error("This is a critical error!");
// Warnings should inform that something went wrong but can be handled by the system.
Log.Warning("This is a warning!");
// Infos should be enabled to display optional, relevant informations.
Log.Info("This is an information.");
// Process logging should be used to notify about important processes/steps.
Log.Process("This is a process.");
// Debug logging can be part of the final release, but should only be enabled when required to find problems.
Log.Debug("This is a debug message.");
/// Temporary logging should only be used during development and should completely be removed on final releases.
/// This kind of logging will always be executed. No matter what Log Level was chosen.
Log.Temp("Just log something temporary ...");
that's it 😮)
Of course, you can use interpolated strings to log content of variables.
Log.Warning($"Sorry, I can`t divide {a} by {b}!");
This library comes with the following loggers:
ConsoleLogger
... log to the console using Console.WriteConsoleColoredLogger
... log colored text to the console using Console.WriteDebugLogger
... Debug logger using Debug.WriteNullLogger
... simple no operation logger
It is easy to write your own logger ...
/// <summary>
/// A logger that show log messages using windows MessageBox.
/// </summary>
public class MessageBoxLogger : BaseLogger
{
public override void Log(LogLevel level, string message)
{
System.Windows.MessageBox.Show(message);
}
}
... and let it only show error messages:
Log.Register(new MessageBoxLogger()
{
MinLevel = LogLevel.Error
});
String extensions
"abc".Repeat(3); // result: "abcabcabc"
"abc".Reverse(); // result: "cba"
"Hello World".Clip(5); // result: "Hello"
"abc".Base64Encode(); // result: "YWJj";
"YWJj".Base64Decode(); // result: "abc"
int? number = "123".Parse<int>(); // result: 123
FileMode? mode = "Append".Parse<FileMode>(); // result: FileMode.Append
FileMode? mode = "Append".ToEnum<FileMode>(); // result: FileMode.Append
DateTime? dateTime = "04/02/1981 10:51:17".ToDateTime(); // result: DateTime object
TimeSpan? timeSpan = "1:23:45".ToTimeSpan(); // result: TimeSpan object
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.