mirror of
https://github.com/Febbweiss/log-generator.git
synced 2026-03-04 22:25:40 +00:00
Use "universal" log syntax (parsing based on kv)
This commit is contained in:
@@ -11,7 +11,7 @@ import java.util.Scanner;
|
|||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
private static final String LOG_SEPARATOR = " - ";
|
private static final String LOG_SEPARATOR = ",";
|
||||||
private static final Logger log = LoggerFactory.getLogger(Utils.class);
|
private static final Logger log = LoggerFactory.getLogger(Utils.class);
|
||||||
private static final List<String> ips = new ArrayList<String>();
|
private static final List<String> ips = new ArrayList<String>();
|
||||||
private static final List<String> products = new ArrayList<String>();
|
private static final List<String> products = new ArrayList<String>();
|
||||||
@@ -54,16 +54,20 @@ public class Utils {
|
|||||||
String sex = "M";
|
String sex = "M";
|
||||||
if (id % 3 == 0) sex = "F";
|
if (id % 3 == 0) sex = "F";
|
||||||
return new StringBuilder()
|
return new StringBuilder()
|
||||||
.append("client").append((id%1000)+1).append("@gmail.com")
|
.append("email=")
|
||||||
|
.append("client").append((id % 1000) + 1).append("@gmail.com")
|
||||||
.append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
|
.append("sex=")
|
||||||
.append(sex)
|
.append(sex)
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRandomSell(long id) {
|
public static String getRandomSell(long id) {
|
||||||
return new StringBuilder()
|
return new StringBuilder()
|
||||||
|
.append("id=")
|
||||||
.append(id)
|
.append(id)
|
||||||
.append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
|
.append("ip=")
|
||||||
.append(getRandomIP())
|
.append(getRandomIP())
|
||||||
.append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
.append(getRandomClient(id))
|
.append(getRandomClient(id))
|
||||||
@@ -74,25 +78,31 @@ public class Utils {
|
|||||||
|
|
||||||
public static String getRandomSearch(long id) {
|
public static String getRandomSearch(long id) {
|
||||||
StringBuilder sb = new StringBuilder()
|
StringBuilder sb = new StringBuilder()
|
||||||
|
.append("id=")
|
||||||
.append(id)
|
.append(id)
|
||||||
.append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
|
.append("ip=")
|
||||||
.append(getRandomIP())
|
.append(getRandomIP())
|
||||||
.append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
|
.append("cat=")
|
||||||
.append(getRandomFromArray(categories.values()));
|
.append(getRandomFromArray(categories.values()));
|
||||||
|
|
||||||
sb.append(LOG_SEPARATOR);
|
|
||||||
if (id % 4 == 0) {
|
if (id % 4 == 0) {
|
||||||
sb.append(getRandomFromArray(matierials.values()));
|
sb.append(LOG_SEPARATOR)
|
||||||
|
.append("mat=")
|
||||||
|
.append(getRandomFromArray(matierials.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(LOG_SEPARATOR);
|
|
||||||
if (id % 3 == 0) {
|
if (id % 3 == 0) {
|
||||||
sb.append(getRandomFromArray(colors.values()));
|
sb.append(LOG_SEPARATOR)
|
||||||
|
.append("color=")
|
||||||
|
.append(getRandomFromArray(colors.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(LOG_SEPARATOR);
|
|
||||||
if (id % 2 == 0) {
|
if (id % 2 == 0) {
|
||||||
sb.append(getRandomFromArray(sizes.values()));
|
sb.append(LOG_SEPARATOR)
|
||||||
|
.append("size=")
|
||||||
|
.append(getRandomFromArray(sizes.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
@@ -101,28 +111,33 @@ public class Utils {
|
|||||||
private static void initProducts(int n) {
|
private static void initProducts(int n) {
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
StringBuilder sb = new StringBuilder()
|
StringBuilder sb = new StringBuilder()
|
||||||
.append("ref:" + (i + 1))
|
.append("ref=" + (i + 1))
|
||||||
.append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
|
.append("cat=")
|
||||||
.append(getRandomFromArray(categories.values()))
|
.append(getRandomFromArray(categories.values()))
|
||||||
.append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
|
.append("mat=")
|
||||||
.append(getRandomFromArray(matierials.values()))
|
.append(getRandomFromArray(matierials.values()))
|
||||||
.append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
|
.append("color=")
|
||||||
.append(getRandomFromArray(colors.values()))
|
.append(getRandomFromArray(colors.values()))
|
||||||
.append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
|
.append("size=")
|
||||||
.append(getRandomFromArray(sizes.values()))
|
.append(getRandomFromArray(sizes.values()))
|
||||||
.append(LOG_SEPARATOR)
|
.append(LOG_SEPARATOR)
|
||||||
|
.append("price=")
|
||||||
.append(getRandomPrice());
|
.append(getRandomPrice());
|
||||||
products.add(sb.toString());
|
products.add(sb.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum sizes { XS, S, M, L, XL }
|
private enum sizes {XS, S, M, L, XL}
|
||||||
|
|
||||||
private enum colors { BLANC, NOIR, BLEU, VERT, ROSE, MARRON }
|
private enum colors {BLANC, NOIR, BLEU, VERT, ROSE, MARRON}
|
||||||
|
|
||||||
private enum categories { TSHIRT, DEBARDEUR, PULL, BOXER, CALCON, SLIP }
|
private enum categories {TSHIRT, DEBARDEUR, PULL, BOXER, CALCON, SLIP}
|
||||||
|
|
||||||
private enum matierials { COTON, SOIE, SYNTHETIQUE }
|
private enum matierials {COTON, SOIE, SYNTHETIQUE}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
readFromFile("ips.txt", ips);
|
readFromFile("ips.txt", ips);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>
|
<pattern>
|
||||||
%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
|
%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %level %logger - %msg%n
|
||||||
</pattern>
|
</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|||||||
Reference in New Issue
Block a user