Skip to content

File size checking & log-file reopening #18

Closed
shikharvashistha wants to merge 9 commits intoMrAnno:file-rotationfrom
shikharvashistha:file-rotation
Closed

File size checking & log-file reopening #18
shikharvashistha wants to merge 9 commits intoMrAnno:file-rotationfrom
shikharvashistha:file-rotation

Conversation

@shikharvashistha
Copy link

@shikharvashistha shikharvashistha commented Aug 28, 2022

This pull implements the functionality to check file size for rotation & reopening if required.

@github-actions
Copy link

No news file has been detected. Please write one, if applicable.

This commit introduces functionality for setting up date format based of last_rotation_time

Signed-off-by: Shikhar Vashistha <[email protected]>
This commit includes the file size checking and renaming if it exceeds the desired size

Signed-off-by: Shikhar Vashistha <[email protected]>
This commit introduces few fixes to file size checking and rotation including reopening the log file based of the request

Signed-off-by: Shikhar Vashistha <[email protected]>
@shikharvashistha shikharvashistha changed the title File size checking File size checking & log-file reopening Aug 29, 2022
@shikharvashistha shikharvashistha force-pushed the file-rotation branch 3 times, most recently from 79dac81 to ccd0062 Compare September 3, 2022 04:01
This commit adds functional test for file-rotation plugin

Signed-off-by: Shikhar Vashistha <[email protected]>
Added file reopener struct to file-signal.h

Signed-off-by: Shikhar Vashistha <[email protected]>
This commit adds reopening of a file via a flush signal

Signed-off-by: Shikhar Vashistha <[email protected]>
This commit adds the functionality to reopen the destination file via reopener

Signed-off-by: Shikhar Vashistha <[email protected]>
@shikharvashistha shikharvashistha force-pushed the file-rotation branch 2 times, most recently from e7f38b7 to cf12e49 Compare September 15, 2022 15:18

g_free(new_filename);

self->number_of_time_rotated++;
Copy link
Owner

@MrAnno MrAnno Sep 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I see you've started working on the rotate() option. The implementation of this option is not trivial: we need to check already existing files and take actions based on what we found in the directory: rename existing 1, 2, 3-suffixed files so that we can use the "1" prefix for the currently rotated file, delete the file that falls out of the rotate(N) range, etc.

An in-memory counter is not enough here, as we'd accidentally override existing files after restarting syslog-ng.

(I'm more than happy if you're willing to work on it, but I'd like to mention that it's not a requirement for the project.)

Copy link
Author

@shikharvashistha shikharvashistha Sep 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have implemented here kindly have a look

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, it is starting to take shape. number_of_time_rotated is still a memory-only value, this feature should work properly between restarts too, which requires checking already existing rotated files on the disk.

Copy link
Author

@shikharvashistha shikharvashistha Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will take care of that issue.

This commit introduces a new option to set number of file rotations possible and few validation checks

Signed-off-by: Shikhar Vashistha <[email protected]>
@shikharvashistha
Copy link
Author

Hi @MrAnno, can we consider winding up the project?

Copy link
Owner

@MrAnno MrAnno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

Please consider fixing the above additional review notes (or reverting back to the non-rotate() version of the PR.

After that, please open a pull request against syslog-ng/syslog-ng.
Please don't forget to read our contribution guide, especially the section about pull requests:
https://github.com/syslog-ng/syslog-ng/blob/master/CONTRIBUTING.md#pull-requests

A few rounds of review will be done there too.
That may slip past the project timeline, but I hope you will still be available from time to time.


g_free(new_filename);

self->number_of_time_rotated++;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, it is starting to take shape. number_of_time_rotated is still a memory-only value, this feature should work properly between restarts too, which requires checking already existing rotated files on the disk.

This commit introduces checking file everytime on disk

Signed-off-by: Shikhar Vashistha <[email protected]>
@shikharvashistha
Copy link
Author

Thank you.

Please consider fixing the above additional review notes (or reverting back to the non-rotate() version of the PR.

After that, please open a pull request against syslog-ng/syslog-ng. Please don't forget to read our contribution guide, especially the section about pull requests: https://github.com/syslog-ng/syslog-ng/blob/master/CONTRIBUTING.md#pull-requests

A few rounds of review will be done there too. That may slip past the project timeline, but I hope you will still be available from time to time.

Yeah I'll be available for the review

@MrAnno MrAnno closed this Sep 20, 2022
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

Successfully merging this pull request may close these issues.

2 participants