You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.5 KiB
1.5 KiB
Implementation
Log File Location
- Path:
/var/log/declpac.log - Single merged log file (stdout + stderr intermingled in order of arrival)
State-Modifying Functions (need logging)
SyncPackages()-pacman -S --needed <packages>InstallAUR()-git clone+makepkg -si --noconfirmMarkAllAsDeps()-pacman -D --asdepsMarkAsExplicit()-pacman -D --asexplicit <packages>CleanupOrphans()-pacman -Rns
Functions to Skip (read-only)
DryRun()- queries onlygetInstalledCount()- pacman -Qq
Execution Patterns
| Pattern | Functions | How |
|---|---|---|
| Captured | All state-modifying functions | capture output, write to log with single timestamp at start, write to terminal |
One Timestamp Per Tool Call
Instead of streaming with MultiWriter (multiple timestamps), each state-modifying function:
- Writes timestamp + operation name to log
- Runs command, captures output
- Writes captured output to log
- Writes output to terminal
This ensures exactly 1 timestamp print per tool call.
Error Handling
- Write error to log BEFORE returning from function
- Print error to stderr so user sees it
Dependencies
- Add to imports:
os,path/filepath
Flow in Sync() or main entrypoint
- Call
OpenLog()at program start, defer close - Each state-modifying function calls
state.Write()with timestamp prefix
Wire into main.go
- Open log at start of
run() - Pass log writer to pacman package (via exported function or global)