@@ -516,7 +516,14 @@ static int mkpath(struct flb_output_instance *ins, const char *dir)
516516/* Function to check if file size exceeds max size in MB */
517517static int should_rotate_file (struct flb_logrotate_conf * ctx )
518518{
519- return ctx -> current_file_size >= ctx -> max_size ;
519+ if (ctx -> current_file_size >= ctx -> max_size ) {
520+ flb_plg_info (ctx -> ins , "going to rotate file: current size=%zu max size=%zu" , ctx -> current_file_size , ctx -> max_size );
521+ return 1 ;
522+ }
523+ else {
524+ flb_plg_debug (ctx -> ins , "file should not be rotated: current size=%zu max size=%zu" , ctx -> current_file_size , ctx -> max_size );
525+ return 0 ;
526+ }
520527}
521528
522529/* Function to update file size counter using current file position */
@@ -725,7 +732,7 @@ static int rotate_file(struct flb_logrotate_conf *ctx, const char *filename)
725732 /* If gzip is enabled, compress the rotated file */
726733 if (ctx -> gzip == FLB_TRUE ) {
727734 snprintf (gzip_filename , PATH_MAX - 1 , "%s.gz" , rotated_filename );
728-
735+ flb_plg_debug ( ctx -> ins , "compressing file: %s to %s" , rotated_filename , gzip_filename );
729736 ret = gzip_compress_file (rotated_filename , gzip_filename , ctx -> ins );
730737 if (ret == 0 ) {
731738 /* Remove the uncompressed file */
@@ -737,7 +744,7 @@ static int rotate_file(struct flb_logrotate_conf *ctx, const char *filename)
737744 return -1 ;
738745 }
739746 } else {
740- flb_plg_debug (ctx -> ins , "rotated file: %s" , rotated_filename );
747+ flb_plg_debug (ctx -> ins , "rotated file: %s (no compression) " , rotated_filename );
741748 }
742749
743750 return 0 ;
@@ -753,7 +760,7 @@ static int cleanup_old_files(struct flb_logrotate_conf *ctx, const char *directo
753760 char * * files = NULL ;
754761 int file_count = 0 ;
755762 int max_files = ctx -> max_files ;
756- int i ;
763+ int i , j ;
757764
758765 /* Create pattern to match rotated files */
759766 snprintf (pattern , PATH_MAX - 1 , "%s." , base_filename );
@@ -797,7 +804,7 @@ static int cleanup_old_files(struct flb_logrotate_conf *ctx, const char *directo
797804
798805 /* Sort files by modification time (oldest first) */
799806 for (i = 0 ; i < file_count - 1 ; i ++ ) {
800- for (int j = i + 1 ; j < file_count ; j ++ ) {
807+ for (j = i + 1 ; j < file_count ; j ++ ) {
801808 struct stat st1 , st2 ;
802809 if (stat (files [i ], & st1 ) == 0 && stat (files [j ], & st2 ) == 0 ) {
803810 if (st1 .st_mtime > st2 .st_mtime ) {
0 commit comments