librato/papertrail-cookbook — pull request #8 by anujbiyani (2013-05-02 23:00:12+00:00)
Title: use the filename when naming the state file instead of a sha

This pull request changes the filename for state files from `state_file_crazyhex` to `state_file_filename` where `filename` is the name of the file that is being watched.

If a user is using logrotate with copytruncate (which most Rails users should/are), then the following happens:
1. rsyslog's state file `state_file_crazyhex` points at byte 0
2. logs fill up, `state_file_crazyhex` points to byte n
3. logrotate triggers with copytruncate (copies logfile to a duplicate, then truncates the original file so that open file descriptors are not broken)
4. `state_file_crazyhex` still points to byte n, but target log is at byte 0
5. rsyslog doesn't transmit anything until target log fills up past byte n

Logrotate supports a `postrotate` config command that can be used to clear out the state file if the state file is known, but it seems hokey to interact with a file that has a generated sha in its name.

I'm also not sure why a sha is even being used; since it's already unique for a given filename, and there's no reason to obscure the filename, using the filename should preserve whatever functionality using a sha offered while also providing a more clear handle for logrotate to mess with.