Unit Noso.Debug

Description

Unit to implement debug functionalities on Noso.

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Record TFileManager Record for file management.
Record TLogNonDisk Record for logging non-disk operations.
Record TPerformanceStats Record to hold performance statistics
Record TThreadManager Record for thread management.

Functions and Procedures

procedure AddFileProcess(const FileType, FileName, Peer: String; const TimeStamp: Int64);
procedure AddNewOpenThread(const ThreadName: String; const TimeStamp: Int64);
function CloseFileProcess(const FileType, FileName, Peer: String; const TimeStamp: Int64): Int64;
procedure CloseOpenThread(const ThreadName: String);
procedure CreateNewLog(const Name: String; const FileName: String = '');
function GetDeepDebugLine(out Line: String): Boolean;
function GetFileProcessCopy(): TFileManagerArray;
function GetLogLine(const Tag: String; out Line: String): Boolean;
function GetProcessCopy(): TThreadManagerArray;
procedure InitializeDeepDebug(const LogFileName: String; const SysInfo: String = '');
function LogPerformanceToFile(const Destination: String): Boolean;
procedure StartPerformanceMeasurement(const Tag: String);
function StopPerformanceMeasurement(const Tag: String): Int64;
procedure ToDeepDebug(const Line: String);
procedure ToLog(const Tag, Line: String);
procedure UpdateOpenThread(const ThreadName: String; const TimeStamp: Int64);

Types

TFileManagerArray = specialize TArray<TFileManager>;
TThreadManagerArray = specialize TArray<TThreadManager>;

Variables

DeepDebugFilename: String = '';
DeepDebugLock: TRTLCriticalSection;
DeepDebugLogStringList: TStringList;
EnablePerformanceLogging: Boolean = False;
FileManagerLock: TRTLCriticalSection;
FileManagers: array of TFileManager;
NonDiskLogs: array of TLogNonDisk;
NonDisksLock: array of TRTLCriticalSection;
NonDiskStringLists: array of TStringList;
PerformanceStats: array of TPerformanceStats;
ProcessList: array of TThreadManager;
ThreadManagerLock: TRTLCriticalSection;

Description

Functions and Procedures

procedure AddFileProcess(const FileType, FileName, Peer: String; const TimeStamp: Int64);

Adds a new file process to the file management list.

Parameters
FileType
Type of the file.
FileName
Name of the file.
Peer
Peer associated with the file.
TimeStamp
Timestamp when the file process started.
procedure AddNewOpenThread(const ThreadName: String; const TimeStamp: Int64);

Adds a new open thread to the thread management list.

Parameters
ThreadName
Name of the thread.
TimeStamp
Timestamp when the thread was created.
function CloseFileProcess(const FileType, FileName, Peer: String; const TimeStamp: Int64): Int64;

Closes a file process and returns the elapsed time.

Parameters
FileType
Type of the file.
FileName
Name of the file.
Peer
Peer associated with the file.
TimeStamp
Timestamp when the file process ended.
Returns

The elapsed time in milliseconds.

procedure CloseOpenThread(const ThreadName: String);

Closes an open thread.

Parameters
ThreadName
Name of the thread to close.
procedure CreateNewLog(const Name: String; const FileName: String = '');

Creates a new log with a specified name and optional file.

Parameters
Name
Name of the log.
FileName
Optional log file name.
function GetDeepDebugLine(out Line: String): Boolean;

Retrieves the oldest line from the deep debug log.

Parameters
Line
Output parameter containing the content of the log line.
Returns

True if the line was successfully retrieved, otherwise False.

function GetFileProcessCopy(): TFileManagerArray;

Retrieves the current list of file processes.

Returns

An array of file management records.

function GetLogLine(const Tag: String; out Line: String): Boolean;

Retrieves the oldest log line for a specified log.

Parameters
Tag
Identifier for the log.
Line
Output parameter containing the content of the log line.
Returns

True if the line was successfully retrieved, otherwise False.

function GetProcessCopy(): TThreadManagerArray;

Retrieves the current list of open threads.

Returns

An array of thread management records.

procedure InitializeDeepDebug(const LogFileName: String; const SysInfo: String = '');

Initializes deep debugging with a specified log file and optional system information.

Parameters
LogFileName
Filename for the deep debug log.
SysInfo
Optional system information.
function LogPerformanceToFile(const Destination: String): Boolean;

Logs performance statistics to a specified file. The output includes the tag, count, maximum time, and average time for each tag.

Parameters
Destination
File path where the performance statistics will be saved.
Returns

True if the logging was successful, otherwise False.

procedure StartPerformanceMeasurement(const Tag: String);

Starts performance measurement for a given tag by storing the current timestamp. If the tag already exists, it updates the start time and increments the count.

Parameters
Tag
Identifier for the performance measurement.
function StopPerformanceMeasurement(const Tag: String): Int64;

Stops performance measurement for a given tag and calculates the duration. Updates the total, max, min, and average times for the tag.

Parameters
Tag
Identifier for the performance measurement.
Returns

The duration of the measurement in milliseconds.

procedure ToDeepDebug(const Line: String);

Adds a new line to the deep debug log.

Parameters
Line
Content of the line to append.
procedure ToLog(const Tag, Line: String);

Appends a new line to a specified log.

Parameters
Tag
Identifier for the log.
Line
Content of the new line to append.
procedure UpdateOpenThread(const ThreadName: String; const TimeStamp: Int64);

Updates the timestamp of an existing thread.

Parameters
ThreadName
Name of the thread.
TimeStamp
New timestamp for the thread.

Types

TFileManagerArray = specialize TArray<TFileManager>;

Array of file management records.

TThreadManagerArray = specialize TArray<TThreadManager>;

Array of thread management records.

Variables

DeepDebugFilename: String = '';

Filename for deep debug logs.

DeepDebugLock: TRTLCriticalSection;

Critical section for deep debugging logs.

DeepDebugLogStringList: TStringList;

String list for deep debugging logs.

EnablePerformanceLogging: Boolean = False;

Flag to enable or disable performance logging.

FileManagerLock: TRTLCriticalSection;

Critical section for file management.

FileManagers: array of TFileManager;

Array of file management records.

NonDiskLogs: array of TLogNonDisk;

Array of non-disk log entries.

NonDisksLock: array of TRTLCriticalSection;

Array of critical sections for managing non-disk logs.

NonDiskStringLists: array of TStringList;

Array of string lists associated with non-disk logs.

PerformanceStats: array of TPerformanceStats;

Array to store performance statistics.

ProcessList: array of TThreadManager;

Array of thread management records.

ThreadManagerLock: TRTLCriticalSection;

Critical section for thread management.


Generated by PasDoc 0.16.0-snapshot.