Skip to content

Commit

Permalink
Add custom launchd log - mac unified logging sucks
Browse files Browse the repository at this point in the history
While trying to help people for whom the launchd job failed, we found it
very difficult to find the entries in the new(ish) MacOS unified logging
thing, so update the launchd job to write output to a temporary log file.

The file is intentionally saved in /tmp and overwritten each time the
launchd job runs to avoid having to deal with permissions or rotation.

File name matches the plist name, e.g. homebrew.mxcl.aws-rotate-iam-keys.log
  • Loading branch information
mmrwoods committed Feb 12, 2019
1 parent 5e73f80 commit fa5fb47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Formula/aws-rotate-iam-keys.rb
Expand Up @@ -57,8 +57,12 @@ def plist; <<~EOS
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>( cat ~/.aws-rotate-iam-keys 2>/dev/null || cat #{etc}/aws-rotate-iam-keys ) | while read line; do aws-rotate-iam-keys $line; done</string>
<string>cp /dev/null /tmp/#{plist_name}.log ; ( cat ~/.aws-rotate-iam-keys 2>/dev/null || cat #{etc}/aws-rotate-iam-keys ) | while read line; do aws-rotate-iam-keys $line; done</string>
</array>
<key>StandardOutPath</key>
<string>/tmp/#{plist_name}.log</string>
<key>StandardErrorPath</key>
<string>/tmp/#{plist_name}.log</string>
<key>RunAtLoad</key>
<true/>
<key>StartCalendarInterval</key>
Expand Down
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -204,7 +204,12 @@ aws iam list-access-keys --profile default
```

If it hasn't worked, check the MacOS system log for error entries matching
`aws-rotate-iam-keys`.
`aws-rotate-iam-keys`. If you can't find anything useful, the launchd job also
writes output to a file in the `/tmp` directory matching the job name, e.g.

```
/tmp/homebrew.mxcl.aws-rotate-iam-keys.log
```

### Other Linux

Expand Down
7 changes: 6 additions & 1 deletion README.template.md
Expand Up @@ -204,7 +204,12 @@ aws iam list-access-keys --profile default
```

If it hasn't worked, check the MacOS system log for error entries matching
`aws-rotate-iam-keys`.
`aws-rotate-iam-keys`. If you can't find anything useful, the launchd job also
writes output to a file in the `/tmp` directory matching the job name, e.g.

```
/tmp/homebrew.mxcl.aws-rotate-iam-keys.log
```

### Other Linux

Expand Down

0 comments on commit fa5fb47

Please sign in to comment.