Reading Log Files
Relevant source files
The following files were used as context for generating this wiki page:
The Pulsar Dome Driver incorporates a comprehensive logging system to facilitate diagnostics, debugging, and monitoring of the driver's operations. The system is built around two distinct logger classes: a primary, configurable FileLogger for main driver activities and a secondary, static WatchdogLogger for isolated, fail-safe logging. Configuration is managed through the ASCOM profile and can be set via the driver's settings dialog.
This document details the architecture of the logging system, the format of the log files, and how to configure logging levels and locations.
Logging Architecture
The driver utilizes two separate logging mechanisms to handle different aspects of its operation.
FileLogger (Primary Logger)
The FileLogger is the main logging utility used throughout the driver for recording connection status, commands, polling cycles, errors, and other operational events. It is instantiated at driver startup and its behavior is controlled by settings stored in the ASCOM profile.
This diagram shows the structure of the FileLogger class.
Sources: Diagnostics/FileLogger.cs:7-20
The initialization process involves reading configuration from the ASCOM profile, constructing the log file path, and creating the FileLogger instance.
This sequence diagram illustrates the initialization flow.
WatchdogLogger (Static Logger)
The WatchdogLogger is a simple, static logger designed for a specific, high-reliability purpose. It logs messages from the action watchdog to a hardcoded location. Its key design feature is to "fail silently"—if a logging error occurs, it will not crash the watchdog process, ensuring the primary monitoring function is not compromised.
- Path:
D:\OneDrive\Documents\Logs\WatchdogLog_{yyyyMMdd}.txt - Format:
[yyyy-MM-dd HH:mm:ss.fff] {message} - Implementation: Uses a static lock and
File.AppendAllText.
Sources: MQTT/WatchDogLogger.cs:7-31
Log File Format
The format of the log entries is designed for clarity and easy parsing, providing essential context for each event.
FileLogger Format
Each line logged by FileLogger follows a standardized structure:
[{timestamp}] {levelLabel} [Thread:{threadId}] {message}
timestamp: UTC time inyyyy-MM-dd HH:mm:ss.fffformat.levelLabel: The severity of the log entry (e.g.,ERROR,INFO,DEBUG).threadId: The managed thread ID that generated the log entry.message: The descriptive log message.
Example log entry:
[2023-10-27 10:30:00.123] Info [Thread:15] Serial port COM3 opened.
Sources: Diagnostics/FileLogger.cs:78-84
WatchdogLogger Format
The WatchdogLogger uses a simpler format:
[{timestamp}] {message}
timestamp: Local time inyyyy-MM-dd HH:mm:ss.fffformat.message: The descriptive log message.
Sources: MQTT/WatchDogLogger.cs:19-22
Configuration
Logging behavior is configured through the driver's setup dialog, and the settings are stored in the ASCOM profile (Windows Registry).
Configuration Options
The following table summarizes the logging-related settings.
| Setting | UI Control | Registry Key | Description | Default |
|---|---|---|---|---|
| Log File Location | txtBoxLogLocation | LogLocation | The directory path where the log file will be created. | MyDocuments\Logs |
| Enable Debug Log | chkBoxDebugLog | DebugLog | If checked, DEBUG level messages are written to the log. | false |
| Enable Trace Log | chkBoxTraceLog | TraceLog | If checked, TRACE level messages are written to the log. | false |
Sources: Config/ConfigManager.cs:122-130, 220-246, UI/SettingsForm.cs:25-58, 86-111, UI/SettingsForm.Designer.cs
Log Levels
The FileLogger filters messages based on a LogLevel enum. The logger is initialized to the Trace level, but the DebugLog and TraceLog boolean flags provide the final control over whether messages at these levels are actually written.
This flowchart shows the logic within the FileLogger.Log method.
The available log levels are:
| Level | Value | Description |
|---|---|---|
None | 0 | No logging. |
Error | 1 | Critical errors that may affect functionality. |
Warning | 2 | Potential issues or non-critical errors. |
Info | 3 | General operational information (e.g., connections, commands). |
Debug | 4 | Detailed information for debugging purposes. |
Trace | 5 | Highly detailed, verbose information for deep diagnostics. |
Sources: Config/ConfigManager.cs:5-13
Summary
The dual-logger system in the Pulsar Dome Driver provides robust and configurable event recording. The main FileLogger captures the driver's operational flow, with its verbosity controlled via the settings UI. The separate, fail-safe WatchdogLogger ensures that critical monitoring functions can log their status without risk of interruption. Understanding these log files and their configuration is essential for troubleshooting and monitoring the dome's behavior.