Pcornel
Automation · Scripting

Logging

Cheat sheet · https://pcornel.dk/topic.php?topic=5223

Back to the Topic

Answer

Script Logging creates attributable execution evidence for decisions, actions, failures and timing. Useful logs are structured enough to correlate a run without exposing secrets or being mistaken for proof of target state.

Remember

  • Log emitted ≠ action succeeded; logging records what the script observed or intended, not independent target truth.
  • Verbose logging ≠ useful evidence; volume without correlation, structure or severity can hide the failure path.
  • No log entry ≠ action did not occur; logging may fail, be filtered or terminate before flush.
  • Debug detail ≠ safe to retain; secrets, tokens and sensitive payloads require redaction.

First checks

  • logger -t <script> 'message' — syslog from Bash
  • Write-Information / Start-Transcript — PowerShell logging
  • python3 -c 'import logging' — Python logging module

Verify in this order

action → log line → central log

Where it usually breaks

A log record proves only that the logging path produced a message; it does not independently prove the external action or target state described by that message.

Logging scripting boundary map

BoundaryHealthy evidenceSuspicious evidence
Input / runtimeEffective inputs, runtime, working context and dependency versions are explicitHidden defaults, stale environment, wrong interpreter/path or unvalidated input
Logic / executionBranch/function/module decisions and external actions expose per-operation resultsSwallowed failures, shell reinterpretation, blind retries or last-result-wins behavior
Result / proofExit/exception/log evidence is correlated with independent target read-backProcess success or printed output treated as target success
Recovery / troubleshootingFirst failed boundary is preserved, changed minimally and retestedRandom edits, catch-all suppression or evidence destroyed before diagnosis

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5223

Confirmation

Confirm action

Continue?