BannisterLake.NET.BLSoft 2.0.6

dotnet add package BannisterLake.NET.BLSoft --version 2.0.6
NuGet\Install-Package BannisterLake.NET.BLSoft -Version 2.0.6
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="BannisterLake.NET.BLSoft" Version="2.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BannisterLake.NET.BLSoft --version 2.0.6
#r "nuget: BannisterLake.NET.BLSoft, 2.0.6"
#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 BannisterLake.NET.BLSoft as a Cake Addin
#addin nuget:?package=BannisterLake.NET.BLSoft&version=2.0.6

// Install BannisterLake.NET.BLSoft as a Cake Tool
#tool nuget:?package=BannisterLake.NET.BLSoft&version=2.0.6

Bannister Lake - BLSoft

This is a library of functions to help create apps with a common base.

Logging

// Enable using a process id as part of the log file name so each launch of the app has a new log file each day
ErrorLog.LogFileUsePID = allSetting.BLSoft.Logging.UseProcessId;

// Enable the display of milliseconds in the logs instead of only seconds
ErrorLog.LogTimeShowMilliseconds = allSetting.BLSoft.Logging.UseMilliseconds;

// Enable the debug type log messages to be written to the log
ErrorLog.EnableLogType(ErrorLogType.Debug, allSetting.BLSoft.Logging.Debug);

// Enable the warning log messages to be written to the log
ErrorLog.EnableLogType(ErrorLogType.Warning, allSetting.BLSoft.Logging.Warning);

// write the current status of the Performance logging enablement to the log file
ErrorLog.Log(ErrorLogType.Info, $"Performance logging is " + (ErrorLog.IsEnabled(ErrorLogType.Performance) ? "enabled." : "disabled."));

Settings

// save the settings to a JSON file
await BLSoft.Utilities.TrySaveJsonSettings(appSettingsFileName, allSettings);

// load settings into a settings class object
private readonly AppSettings allSettings = new();
IConfiguration AppConfig = new ConfigurationBuilder()
    .SetBasePath(Utilities.BaseCommonAppPath())
    .AddJsonFile(appSettingsFileName, optional: true)
    .Build();

AppConfig.Bind("BLSoft", allSettings.BLSoft);


public class AppSettings
{
    public AppSettings() 
    {
        OtherSettings = new();
        BLSoft = new();
    }
    
    public BLSoft.Settings.BLSoftSettings BLSoft { get; set; }
    public MoreSettings OtherSettings { get; set; }
}	

Performance Timer

// the Performance Timer is integrated with the ErrorLog to record how long tasks take
var performance = PerformanceTimer.Start();
try { ... }
finally
{
    // log entry looks like: 
    // 2023-03-24	9:37:12	Performance: 	    19 ms: My task finished in 19 ms.
    performance.StopTimer("My task finished in {0} ms.");
}

// To create a timer that isn't started immediately
var performance = new PerformanceTimer(...);
...
performance.StartTimer();
try 
{	    
    ... 
	performance.StopTimer("Task A completed in {0} ms.");
}
catch (Exception)
{
    performance.StopTimer("Task A failed after {0} ms.");
	...
}
Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.6 158 6/20/2023
2.0.5 157 4/5/2023
2.0.4 187 3/27/2023

1. Breaking changes

2. New features
  - use Newtonsoft.Json 13.0.3

3. Bug fixes