Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for externalizing rotated_filename_patterns and comparator #35

Open
bobtiernay-okta opened this issue Sep 14, 2017 · 4 comments

Comments

@bobtiernay-okta
Copy link
Contributor

bobtiernay-okta commented Sep 14, 2017

Currently rotated_filename_patterns is hard coded into the library. It should be possible to externalize this so that it can be used with other schemes which are not logrotate or savelog based. This requires that the sorting logic also be externalized for general usage.

@bobtiernay-okta bobtiernay-okta changed the title Add support for externalizing rotated_filename_patterns and compartor Add support for externalizing rotated_filename_patterns and comparator Sep 14, 2017
@bobtiernay-okta
Copy link
Contributor Author

Let me know if you agree with the change and if you have any design thoughts. I'll be happy to open a PR. Thanks!

@czchen
Copy link
Contributor

czchen commented Mar 14, 2018

Any update on this one? We also have the same problem because we use customized log naming scheme.

The worst part is that when _determine_rotated_logfile cannot find the old log file, pygtail leave self._offset as old offset, and it will use old offset against new log file, which will not work because old offset is always greater than new offset. The pygtail will stop.

@bgreenlee
Copy link
Owner

I think having a config file would be a good idea, especially as the list of config flags grows. I don't have time right now to work on this, but I would certainly entertain a PR!

@czchen
Copy link
Contributor

czchen commented Mar 14, 2018

@bgreenlee

I don't quite understand the logic behind the following code in _check_rotated_filename_candidates. Could you help to explain it?

        # savelog(8)
        candidate = "%s.0" % self.filename
        if (exists(candidate) and exists("%s.1.gz" % self.filename) and
            (stat(candidate).st_mtime > stat("%s.1.gz" % self.filename).st_mtime)):
            return candidate

My plan is to add an arg rotated_filename_patterns for caller to determine rotated file patterns in priority order, and the default value of rotated_filename_patterns is the same as pattern in _check_rotated_filename_candidates right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants