Skip to content

Conversation

SagiROosto
Copy link

No description provided.

Copilot

This comment was marked as outdated.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new output plugin out_logrotate to Fluent Bit that provides file output with automatic log rotation capabilities. The plugin extends the basic file output functionality with features like file size-based rotation, automatic compression, and cleanup of old rotated files.

  • Adds logrotate output plugin with rotation, compression, and cleanup features
  • Implements comprehensive test suite with multiple test scenarios
  • Adds CMake build configuration and plugin registration

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
plugins/out_logrotate/logrotate.c Main plugin implementation with rotation logic, compression, and file management
plugins/out_logrotate/logrotate.h Plugin header with format enum definitions
plugins/out_logrotate/CMakeLists.txt Build configuration for the plugin
tests/runtime/out_logrotate.c Comprehensive test suite with 7 test cases
tests/runtime/CMakeLists.txt Test registration configuration
plugins/CMakeLists.txt Plugin registration in main build system
cmake/plugins_options.cmake Build option definition for the plugin
conf/fluent-bit-logrotate.conf Example configuration file

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +97 to +101
struct tm *tm_info = localtime(&now);
char timestamp[32];

strftime(timestamp, sizeof(timestamp), "%Y%m%d_%H%M%S", tm_info);

Copy link
Preview

Copilot AI Sep 1, 2025

Choose a reason for hiding this comment

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

The localtime() function returns a pointer to static data that can be overwritten by subsequent calls in multi-threaded environments. Use localtime_r() for thread safety.

Suggested change
struct tm *tm_info = localtime(&now);
char timestamp[32];
strftime(timestamp, sizeof(timestamp), "%Y%m%d_%H%M%S", tm_info);
struct tm tm_info;
char timestamp[32];
localtime_r(&now, &tm_info);
strftime(timestamp, sizeof(timestamp), "%Y%m%d_%H%M%S", &tm_info);

Copilot uses AI. Check for mistakes.

Copy link

@yuvalDOosto yuvalDOosto left a comment

Choose a reason for hiding this comment

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

Reviewed it together and made the edits on spot :)

@SagiROosto SagiROosto merged commit ad01bd5 into master Sep 3, 2025
SagiROosto added a commit that referenced this pull request Sep 3, 2025
* add logrotate out plugin

* fix gzip

* fix test

* update max_size

* update gzip

* add logs

Signed-off-by: SagiROosto <sagi.rosenthal@oosto.com>
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