]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats-file: add the filename in the warning
authorWilliam Lallemand <wlallemand@haproxy.com>
Tue, 19 Nov 2024 14:42:05 +0000 (15:42 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Tue, 19 Nov 2024 14:49:44 +0000 (15:49 +0100)
Add the name of the stats-file in the warning so it's clear that the
warning was provoked by the stats-file and not the config file.

src/stats-file.c

index 1a77e3182b84e171b87b3443d2617bcfeef8c72c..a26f07e5fd0405475b1275ed5f5f0c5087967e13 100644 (file)
@@ -358,19 +358,19 @@ void apply_stats_file(void)
 
        file = fopen(global.stats_file, "r");
        if (!file) {
-               ha_warning("config: Can't load stats file: cannot open file.\n");
+               ha_warning("config: Can't load stats-file '%s': cannot open file.\n", global.stats_file);
                return;
        }
 
        /* Generate stat columns map indexed by name. */
        if (generate_stat_tree(&st_tree, stat_cols_px)) {
-               ha_warning("config: Can't load stats file: not enough memory.\n");
+               ha_warning("config: Can't load stats-file '%s': not enough memory.\n", global.stats_file);
                goto out;
        }
 
        line = malloc(sizeof(char) * LINESIZE);
        if (!line) {
-               ha_warning("config: Can't load stats file: line alloc error.\n");
+               ha_warning("config: Can't load stats-file '%s': line alloc error.\n", global.stats_file);
                goto out;
        }
 
@@ -388,25 +388,25 @@ void apply_stats_file(void)
                if (*istptr(istline) == '#') {
                        if (parse_header_line(istline, &st_tree, &domain, cols)) {
                                if (!valid_format) {
-                                       ha_warning("config: Invalid stats-file format.\n");
+                                       ha_warning("config: Invalid stats-file format in file '%s'.\n", global.stats_file);
                                        break;
                                }
 
-                               ha_warning("config: Ignored stats-file header line '%d'.\n", linenum);
+                               ha_warning("config: Ignored stats-file header line '%d' in file '%s'.\n", linenum, global.stats_file);
                        }
 
                        valid_format = 1;
                }
                else if (domain != STFILE_DOMAIN_UNSET) {
                        if (parse_stat_line(istline, domain, cols))
-                               ha_warning("config: Ignored stats-file line %d.\n", linenum);
+                               ha_warning("config: Ignored stats-file line %d in file '%s'.\n", linenum, global.stats_file);
                }
                else {
                        /* Stop parsing if first line is not a valid header.
                         * Allows to immediately stop reading garbage file.
                         */
                        if (!valid_format) {
-                               ha_warning("config: Invalid stats-file format.\n");
+                               ha_warning("config: Invalid stats-file format in file '%s'.\n", global.stats_file);
                                break;
                        }
                }