Automation · Scripting
Logging
Cheat sheet · https://pcornel.dk/topic.php?topic=5223
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 BashWrite-Information / Start-Transcript— PowerShell loggingpython3 -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
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Input / runtime | Effective inputs, runtime, working context and dependency versions are explicit | Hidden defaults, stale environment, wrong interpreter/path or unvalidated input |
| Logic / execution | Branch/function/module decisions and external actions expose per-operation results | Swallowed failures, shell reinterpretation, blind retries or last-result-wins behavior |
| Result / proof | Exit/exception/log evidence is correlated with independent target read-back | Process success or printed output treated as target success |
| Recovery / troubleshooting | First failed boundary is preserved, changed minimally and retested | Random 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