PanoramicData.ConsoleExtensions
1.0.16
dotnet add package PanoramicData.ConsoleExtensions --version 1.0.16
NuGet\Install-Package PanoramicData.ConsoleExtensions -Version 1.0.16
<PackageReference Include="PanoramicData.ConsoleExtensions" Version="1.0.16" />
<PackageVersion Include="PanoramicData.ConsoleExtensions" Version="1.0.16" />
<PackageReference Include="PanoramicData.ConsoleExtensions" />
paket add PanoramicData.ConsoleExtensions --version 1.0.16
#r "nuget: PanoramicData.ConsoleExtensions, 1.0.16"
#:package PanoramicData.ConsoleExtensions@1.0.16
#addin nuget:?package=PanoramicData.ConsoleExtensions&version=1.0.16
#tool nuget:?package=PanoramicData.ConsoleExtensions&version=1.0.16
PanoramicData.ConsoleExtensions
Extensions for the System.Console namespace
install-package PanoramicData.ConsoleExtensions
ConsolePlus.ReadPassword
This method provides a simple and safe way to read a password from the command line, including permitting the user to use the backspace key.
using PanoramicData.ConsoleExtensions;
...
Console.Write("Password: ");
var password = ConsolePlus.ReadPassword();
Console.WriteLine();
ConsoleLogger
This class provides a simple ILogger implementation for the command line. It implements colored logging, with control over the color used for each log level and sensible defaults.
Basic Usage
using PanoramicData.ConsoleExtensions;
...
var consoleLogger1 = new ConsoleLogger();
consoleLogger1.LogInformation("The Date is {DateTime:yyyy-MM-dd}", DateTime.UtcNow);
var consoleLogger2 = new ConsoleLogger(new ConsoleLoggerOptions
{
TraceColor = ConsoleColor.DarkYellow,
LogLevel = LogLevel.Debug
});
consoleLogger2.LogTrace("The Date is {DateTime:yyyy-MM-dd}", DateTime.UtcNow);
consoleLogger2.LogError(exception, "Failure occurred at {DateTime:yyyy-MM-dd}", DateTime.UtcNow);
Structured Logging Features
The ConsoleLogger supports advanced structured logging features while maintaining backward compatibility:
Timestamps and Custom Formatting
var options = new ConsoleLoggerOptions
{
IncludeTimestamp = true,
IncludeEventId = true,
TimeFormat = "yyyy-MM-dd HH:mm:ss.fff",
OutputFormat = "{Timestamp} [{Level}] ({EventId}) {Message}"
};
var logger = new ConsoleLogger(options);
logger.LogInformation(new EventId(1001), "User {UserName} logged in", "Alice");
Hyperlink Support
URLs and file paths are automatically detected and made clickable in supported terminals:
var options = new ConsoleLoggerOptions { EnableHyperlinks = true };
var logger = new ConsoleLogger(options);
logger.LogInformation("Visit https://github.com/panoramicdata/PanoramicData.ConsoleExtensions");
logger.LogInformation("Error in file: C:\\Source\\MyProject\\Program.cs");
Exception Formatting
Choose between detailed multi-line or compact single-line exception formatting:
var options = new ConsoleLoggerOptions { SingleLineExceptions = true };
var logger = new ConsoleLogger(options);
logger.LogError(exception, "Operation failed");
Demo Application
A comprehensive demo application is included in the PanoramicData.ConsoleExtensions.Demo
project that showcases all the library features:
- Interactive password reading demonstration
- Default console logger with standard colors and log levels
- Custom console logger with custom colors and log level filtering
- Structured logging examples
- Exception logging examples
To run the demo:
cd PanoramicData.ConsoleExtensions.Demo
dotnet run
Or use the VS Code launch configuration "Run Demo" for easy debugging.
Publishing to NuGet
A PowerShell script publish.ps1
is provided for easy publishing to NuGet.org:
Setup
- Obtain a NuGet API key from https://www.nuget.org/account/apikeys
- Replace the contents of
nuget.key
with your actual API key (the file should contain only the key) - Run the publish script
Usage
# Publish with default settings (Release configuration)
.\publish.ps1
# Specify custom configuration
.\publish.ps1 -Configuration Debug
# Use a different key file
.\publish.ps1 -KeyFile "my-api-key.txt"
# Auto-publish without confirmation prompt
.\publish.ps1 -SkipConfirmation
Windows Users: You can also use publish.bat
which bypasses PowerShell execution policy restrictions.
The script will:
- Validate the API key file exists and contains a valid key
- Build the solution in the specified configuration
- Create the NuGet package
- Prompt for confirmation before publishing
- Publish to NuGet.org
Security Note: The nuget.key
file is automatically excluded from Git via .gitignore
to protect your API key.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added structured logging support with timestamps, event IDs, custom formatting, and hyperlink detection. Maintained full backward compatibility.