Intro

From time to time you may find it useful to set the agent into debug mode to follow what it is doing. This is accomplished in a few different ways.

Windows

To get a log file on windows enable debug mode and the file will be in C:\windows\system32\puck_agent.log

Enable Debug mode

$serviceName = "PuckAgent"
$envKeyPath = "HKLM:\SYSTEM\CurrentControlSet\Services\$serviceName"
$envVarName = "PUCK_LOG"
$envVarValue = "C:\ProgramData\PuckAgent\logs"

# Ensure registry key exists and modify Environment variable
if (-not (Get-ItemProperty -Path $envKeyPath -Name "Environment" -ErrorAction SilentlyContinue)) {
    New-ItemProperty -Path $envKeyPath -Name "Environment" -PropertyType MultiString -Value "$envVarName=$envVarValue"
} else {
    $envList = (Get-ItemProperty -Path $envKeyPath -Name "Environment").Environment
    $envList = $envList | Where-Object { -not ($_ -like "$envVarName=*") }
    $envList += "$envVarName=$envVarValue"
    Set-ItemProperty -Path $envKeyPath -Name "Environment" -Value $envList
}

# Restart the service to apply the change
Restart-Service -Name $serviceName

Disable Debug mode

$serviceName = "PuckAgent"
$envKeyPath = "HKLM:\SYSTEM\CurrentControlSet\Services\$serviceName"
$envVarName = "PUCK_LOG"

# Get existing Environment variables
$envList = (Get-ItemProperty -Path $envKeyPath -Name "Environment" -ErrorAction SilentlyContinue).Environment

if ($envList) {
    # Remove the PUCK_LOG entry
    $updatedList = $envList | Where-Object { -not ($_ -like "$envVarName=*") }

    if ($updatedList.Count -eq 0) {
        # No env vars left — remove the whole Environment value
        Remove-ItemProperty -Path $envKeyPath -Name "Environment"
    } else {
        # Save updated list without PUCK_LOG
        Set-ItemProperty -Path $envKeyPath -Name "Environment" -Value $updatedList
    }

    # Restart the service to apply changes
    Restart-Service -Name $serviceName
} else {
    Write-Output "No Environment variables set for service $serviceName."
}

Linux

For linux you just need to stop the service and run the binary as your users.

systemctl stop puck-tools-agent.service
PUCK_LOG=debug /opt/pucktools/bin/puck-agent --with-systemd