From 1e46e07c4bb46555eaed1354701d950809f99853 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sat, 24 Apr 2021 16:48:30 +0200 Subject: [PATCH] Refactored code. Improved anonymization. --- src/fr/devinsy/logar/app/DryOption.java | 58 ++++ src/fr/devinsy/logar/app/Logar.java | 323 +++++++----------- .../logar/app/anonymizer/Anonymizer.java | 28 +- src/fr/devinsy/logar/app/log/Log.java | 181 +++++++++- src/fr/devinsy/logar/app/log/LogFile.java | 256 ++++++++++++++ src/fr/devinsy/logar/app/log/LogMode.java | 28 ++ src/fr/devinsy/logar/app/log/LogParser.java | 153 +++++++++ src/fr/devinsy/logar/app/log/LogUtils.java | 262 +------------- src/org/april/logar/cli/LogarCLI.java | 21 +- src/org/april/logar/util/Files.java | 58 +++- src/org/april/logar/util/FilesUtils.java | 31 ++ 11 files changed, 914 insertions(+), 485 deletions(-) create mode 100644 src/fr/devinsy/logar/app/DryOption.java create mode 100644 src/fr/devinsy/logar/app/log/LogFile.java create mode 100644 src/fr/devinsy/logar/app/log/LogMode.java create mode 100644 src/fr/devinsy/logar/app/log/LogParser.java diff --git a/src/fr/devinsy/logar/app/DryOption.java b/src/fr/devinsy/logar/app/DryOption.java new file mode 100644 index 0000000..b94bdcc --- /dev/null +++ b/src/fr/devinsy/logar/app/DryOption.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2021 Christian Pierre MOMON + * + * This file is part of Logar, simple tool to manage http log files. + * + * Logar 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. + * + * Logar 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 Logar. If not, see . + */ +package fr.devinsy.logar.app; + +/** + * The Enum DryOption. + */ +public enum DryOption +{ + ON, + OFF; + + /** + * Checks if is off. + * + * @return true, if is off + */ + public boolean isOff() + { + boolean result; + + result = (this == OFF); + + // + return result; + } + + /** + * Checks if is on. + * + * @return true, if is on + */ + public boolean isOn() + { + boolean result; + + result = (this == ON); + + // + return result; + } +} diff --git a/src/fr/devinsy/logar/app/Logar.java b/src/fr/devinsy/logar/app/Logar.java index acbb8da..9da78c3 100644 --- a/src/fr/devinsy/logar/app/Logar.java +++ b/src/fr/devinsy/logar/app/Logar.java @@ -24,11 +24,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.time.LocalDateTime; import java.time.YearMonth; -import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.zip.GZIPOutputStream; import org.apache.commons.io.IOUtils; @@ -41,7 +37,8 @@ import org.slf4j.LoggerFactory; import fr.devinsy.logar.app.anonymizer.Anonymizer; import fr.devinsy.logar.app.log.Log; -import fr.devinsy.logar.app.log.LogUtils; +import fr.devinsy.logar.app.log.LogFile; +import fr.devinsy.logar.app.log.LogParser; /** * The Class Logar. @@ -50,8 +47,7 @@ public final class Logar { private static Logger logger = LoggerFactory.getLogger(Logar.class); - public static Pattern nginxAccessLogLinePattern = Pattern.compile("^\\S+ - [^\\[]+ \\[(?