diff --git a/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java b/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java index 30f1d5d..b290c71 100644 --- a/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java +++ b/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java @@ -254,6 +254,7 @@ public final class StatoolInfosCLI catch (Exception exception) { logger.error("Error with [{}]: {}", input.getAbsoluteFile(), exception.getMessage()); + exception.printStackTrace(); } } } diff --git a/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java b/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java index c20bf32..4c50a47 100644 --- a/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java +++ b/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java @@ -29,7 +29,9 @@ import java.time.Period; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; +import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import java.util.Iterator; import java.util.Locale; @@ -142,6 +144,23 @@ public class StatoolInfosUtils FileUtils.copyURLToFile(source, target, 5000, 5000); } + /** + * Gets the week count of year. + * + * @param year + * the year + * @return the week count of year + */ + public static int getWeekCountOfYear(final int year) + { + int result; + + result = new GregorianCalendar(year, 11, 01).getActualMaximum(Calendar.WEEK_OF_YEAR); + + // + return result; + } + /** * Gets the current time in long format. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/probes/HttpAccessLogAnalyzer.java b/src/fr/devinsy/statoolinfos/htmlize/probes/HttpAccessLogAnalyzer.java new file mode 100644 index 0000000..93f73fc --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/probes/HttpAccessLogAnalyzer.java @@ -0,0 +1,283 @@ +/* + * Copyright (C) 2020-2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize.probes; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.core.StatoolInfosException; + +/** + * The Class HttpAccessLogProber. + */ +public class HttpAccessLogAnalyzer +{ + private static Logger logger = LoggerFactory.getLogger(HttpAccessLogAnalyzer.class); + + public static final String DEFAULT_CHARSET_NAME = "UTF-8"; + + /** + * Instantiates a new http access log prober. + */ + private HttpAccessLogAnalyzer() + { + } + + /** + * Parses the log. + * + * @param line + * the line + * @return the http log + */ + public static HttpLog parseLog(final String line) + { + HttpLog result; + + // + // log_format combined '$remote_addr - $remote_user [$time_local] ' + // '"$request" $status $body_bytes_sent ' + // '"$http_referer" "$http_user_agent"'; + String remoteAddressPattern = "(?[a-zA-F0-9\\\\:\\\\.]+)"; + String remoteUserPattern = "(?\\S+)"; + String timePattern = "(?