pkar.Log 1.2.0

Prefix Reserved
dotnet add package pkar.Log --version 1.2.0
                    
NuGet\Install-Package pkar.Log -Version 1.2.0
                    
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="pkar.Log" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="pkar.Log" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="pkar.Log" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add pkar.Log --version 1.2.0
                    
#r "nuget: pkar.Log, 1.2.0"
                    
#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.
#:package pkar.Log@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=pkar.Log&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=pkar.Log&version=1.2.0
                    
Install as a Cake Tool

This is simple code events log library. It is dedicated for runtime log lifetime, and its main 'strongpoint' is using call stack depth to filter events. Designed to be used as singleton, i.e. all methods are static/shared.

For log entry, it uses LogEntry, based on BaseStruct (from my pkar.StructList Nuget)

properties and delegates

''' <summary>
''' Maximum number of characters in the log.
''' When exceeded, oldest entries are removed until the length is within the limit.
''' Default is 10 MiB (10 * 1024 * 1024 characters).
''' (only messages are counted, not the whole x)    
''' </summary>
Public Shared Property MaxLogCharLen As Integer = 10 * 1024 * 1024

Public Delegate Sub LogAppendedTextEventHandler(linia As String)

''' <summary>
''' Called when a new x is appended to the log.
''' This can be used to update UI elements or other components that need to react to log changes.
''' </summary>
Public Shared Event LogAppendedText As LogAppendedTextEventHandler

Public Delegate Sub LogAppendedEntryEventHandler(linia As LogEntry)

''' <summary>
''' Called when a new x is appended to the log.
''' This can be used to update UI elements or other components that need to react to log changes.
''' </summary>
Public Shared Event LogAppendedStruct As LogAppendedEntryEventHandler

setting LogLevel

''' <summary>
''' How deep log should be - if Append(logLevel > this LogLevel), then x is not appended to log
''' </summary>
Public Shared Property LogLevel As Integer = 1

Public Shared Sub EnableLogging(Optional iLogLevel As Integer = 0)
Public Shared Sub DisableLogging()

clearing log

''' <summary>
''' Clear the log data.
''' This will remove all entries from the log.
''' </summary>
Public Shared Sub ClearLog()

retrieving log entries

''' <summary>
''' Get all log entries, optionally filtered by a string and maximum log level.
''' </summary>
''' <param name="filter">Optional filter string to match against log messages.</param>
''' <param name="maxLevel">Optional maximum log level to include in the results.</param>
''' <returns>List of log entries matching the filter and level criteria.
''' </summary>
Public Shared Function GetLogEntries(Optional filter As String = "", Optional maxLevel As Integer = 1023) As BaseList(Of LogEntry)

''' <summary>
''' Returns all log entries as a single string.
''' </summary>
Public Shared Function GetLogAsString() As String

''' <summary>
''' Force recalculation the total character length of all log entries.
''' </summary>
''' <returns>Total character length of log entries.</returns>
Public Shared Function CalculateLogCharLen() As Integer

''' <summary>
''' Get the current character length of the log.
''' This is the total length of all log messages, not including timestamps or levels.
''' It can be used to monitor the size of the log and manage its growth.
''' </summary>
Public Shared Function GetLogCharLen() As Integer

adding information to log

''' <summary>
''' Append a BaseStruct to the log as a JSON string.
''' </summary>
Public Shared Sub Append(strukt As BaseStruct)

''' <summary>
''' Append Exception to the log.
''' This will include the exception message and optionally the stack trace.
''' </summary>
''' <param name="sTxt">Text to append before the exception message.</param>
''' <param name="ex">Exception to log.</param>
''' <param name="bWithStack">If true, includes the stack trace in the log x.</param>
Public Shared Sub Append(sTxt As String, ex As Exception, Optional bWithStack As Boolean = False)

''' <summary>
''' Append text to the log.
''' </summary>
''' <param name="sText">Text to append.</param>
Public Shared Sub Append(sText As String)


''' <summary>
''' Append a message to the log with a specified log level.
''' The log level determines whether the message will be included in the log based on the current LogLevel setting.
''' If the message exceeds the maximum character length, older entries are removed until within limits.
''' It will also raise events to notify subscribers about the new log x.
''' If it is DEBUG version, message will be sent do Debug.WriteLine as well.
''' </summary>
Public Shared Sub Append(logLevel As Integer, sMsg As String)

''' <summary>
''' Log current method name, with appropriate indent, and given message.
''' This is useful for debugging purposes to see the current execution context.
''' The method name is derived from the stack trace, and the indent level is based on the call stack depth.
''' </summary>
''' <param name="sMsg">Optional message to include in the log x.</param>
Public Shared Sub DumpCurrMethod(Optional sMsg As String = "")

''' <summary>
''' Log message, with appropriate indent (from stack depth and iLovel).
''' </summary>
Public Shared Sub DumpMessage(sMsg As String, Optional iLevel As Integer = 1)

simple file storage

''' <summary>
''' Sends the current log to a file.
''' If no file path is provided, it defaults to a log-lib.txt file in the GetTempPath (on UWP, it will be TempState directory).
''' If the file does not exist, it creates it with a header containing the current date and time.
''' </summary>
Public Sub SendToFile(Optional sFilePathname As String = "")

persistent message - uses pkar.NetConfigs, variable 'appFailData'

''' <summary>
''' Reset the persistent crash message stored in the settings variable 'appFailData'.
''' This will return the current message and clear it from the settings.
''' If settings are not initialized, it will return an empty string.
''' </summary>
Public Shared Function CrashMessageReset() As String

''' <summary>
''' Add persistent crash message to the settings variable 'appFailData'.
''' This will append a timestamped message to the log, which can be used for debugging or error reporting.
''' If settings are not initialized, nothing will happen.
Public Shared Sub CrashMessageAdd(sMsg As String, Optional sMsg1 As String)

''' <summary>
''' Add persisten crash message to the settings variable 'appFailData'.
''' This will append a timestamped message to the log, which can be used for debugging or error reporting.
''' If settings are not initialized, nothing will happen.
''' </summary>
Public Shared Sub CrashMessageAdd(sTxt As String, ex As Exception, Optional bWithStack As Boolean = False)

LogEntry class

''' <summary>
''' Represents a single log entry with a timestamp, log level, and message.
''' </summary>
Public Class LogEntry
    Inherits BaseStruct

    Public Property Timestamp As DateTime
    Public Property Level As Integer
    Public Property Message As String

    Public Sub New(timestamp As DateTime, level As Integer, message As String)

    Public Overrides Function ToString() As String

End Class
Product 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 netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.4 is compatible.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  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 tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.2.0 212 8/5/2025