From 5d3e05d6f190d6c42f5bd66fa1decb979f172190 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Wed, 29 Dec 2021 15:58:04 +0100 Subject: [PATCH] Improved default UTF-8 charset used. --- src/fr/devinsy/statoolinfos/crawl/CrawlJournalFile.java | 2 +- src/fr/devinsy/statoolinfos/htmlize/EditoPage.java | 2 +- src/fr/devinsy/statoolinfos/io/CSVWriter.java | 3 ++- src/fr/devinsy/statoolinfos/metrics/Prober.java | 9 ++++----- .../statoolinfos/metrics/http/HttpAccessLogAnalyzer.java | 3 +-- .../statoolinfos/metrics/http/HttpErrorLogAnalyzer.java | 2 -- .../statoolinfos/metrics/http/HttpLogIterator.java | 2 -- .../statoolinfos/metrics/http/NGinxLogAnalyzer.java | 2 -- .../statoolinfos/properties/PathPropertyUtils.java | 2 +- .../devinsy/statoolinfos/uptime/UptimeJournalFile.java | 2 +- src/fr/devinsy/statoolinfos/util/LineIterator.java | 5 ++--- 11 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/crawl/CrawlJournalFile.java b/src/fr/devinsy/statoolinfos/crawl/CrawlJournalFile.java index 4839954..8e7ec70 100644 --- a/src/fr/devinsy/statoolinfos/crawl/CrawlJournalFile.java +++ b/src/fr/devinsy/statoolinfos/crawl/CrawlJournalFile.java @@ -161,7 +161,7 @@ public class CrawlJournalFile PrintWriter out = null; try { - out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); + out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)); write(out, source); } finally diff --git a/src/fr/devinsy/statoolinfos/htmlize/EditoPage.java b/src/fr/devinsy/statoolinfos/htmlize/EditoPage.java index 4cb54ae..a3b4bf7 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/EditoPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/EditoPage.java @@ -69,7 +69,7 @@ public class EditoPage FileUtils.copyDirectory(editoDirectory, htmlizeDirectory); // Load body edito xhtml file. - edito = FileUtils.readFileToString(editoFile, "UTF-8"); + edito = FileUtils.readFileToString(editoFile, StandardCharsets.UTF_8); edito = XidynUtils.extractBodyContent(edito); } else diff --git a/src/fr/devinsy/statoolinfos/io/CSVWriter.java b/src/fr/devinsy/statoolinfos/io/CSVWriter.java index 25d4544..89f1db3 100644 --- a/src/fr/devinsy/statoolinfos/io/CSVWriter.java +++ b/src/fr/devinsy/statoolinfos/io/CSVWriter.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -57,7 +58,7 @@ public class CSVWriter implements SpreadsheetWriter public CSVWriter(final File file, final char separator) throws UnsupportedEncodingException, FileNotFoundException { this.separator = separator; - this.out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); + this.out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)); this.isNewline = true; } diff --git a/src/fr/devinsy/statoolinfos/metrics/Prober.java b/src/fr/devinsy/statoolinfos/metrics/Prober.java index 8c4d5b2..eac5b7b 100644 --- a/src/fr/devinsy/statoolinfos/metrics/Prober.java +++ b/src/fr/devinsy/statoolinfos/metrics/Prober.java @@ -41,6 +41,7 @@ import fr.devinsy.statoolinfos.core.StatoolInfosUtils; import fr.devinsy.statoolinfos.metrics.http.HttpAccessLogAnalyzer; import fr.devinsy.statoolinfos.metrics.http.HttpErrorLogAnalyzer; import fr.devinsy.statoolinfos.metrics.minetest.MinetestProber; +import fr.devinsy.statoolinfos.metrics.mumble.MumbleProber; import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathProperty; import fr.devinsy.statoolinfos.properties.PathPropertyUtils; @@ -54,8 +55,6 @@ public class Prober { private static Logger logger = LoggerFactory.getLogger(Prober.class); - public static final String DEFAULT_CHARSET_NAME = "UTF-8"; - public static final Pattern YEAR_PATTERN = Pattern.compile("^\\d{4}$"); /** @@ -155,11 +154,11 @@ public class Prober if (types.containsAnyIgnoreCase("Mumble")) { logger.info("== Processing Mumble."); - String source = configuration.getProbeHttpErrorLogSource(); + String source = configuration.get("conf.probe.mumble.logs"); logger.info("source=[{}]", source); - // PathCounters data = HttpErrorLogAnalyzer.probe(source); - // counters.putAll(data); + PathCounters data = MumbleProber.probe(source); + counters.putAll(data); } // Filter. diff --git a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java index c6f10ee..908a264 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java +++ b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java @@ -31,6 +31,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.metrics.IpCounters; import fr.devinsy.statoolinfos.metrics.PathCounters; import fr.devinsy.statoolinfos.util.FilesUtils; import fr.devinsy.statoolinfos.util.LineIterator; @@ -42,8 +43,6 @@ public class HttpAccessLogAnalyzer { private static Logger logger = LoggerFactory.getLogger(HttpAccessLogAnalyzer.class); - public static final String DEFAULT_CHARSET_NAME = "UTF-8"; - // log_format combined '$remote_addr - $remote_user [$time_local] ' // '"$request" $status $body_bytes_sent ' // '"$http_referer" "$http_user_agent"'; diff --git a/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java index 8d5012f..c5e95f0 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java +++ b/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java @@ -41,8 +41,6 @@ public class HttpErrorLogAnalyzer { private static Logger logger = LoggerFactory.getLogger(HttpErrorLogAnalyzer.class); - public static final String DEFAULT_CHARSET_NAME = "UTF-8"; - public static final Pattern NGINX_ERROR_PATTERN = Pattern.compile("^(?