aboutsummaryrefslogtreecommitdiffstats
path: root/logserver
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2019-03-26 18:01:45 +0100
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2019-03-26 18:02:28 +0100
commit7ba6fbef28e5cc59b4cd993a836b9f5a4ae34110 (patch)
tree94af096234189c2f261c16e2cc8b66a4408e3e8f /logserver
parentdc46e712efefb2324869a1abf7baac198b33778e (diff)
Remove unused log formatters from logserver
Diffstat (limited to 'logserver')
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/formatter/LogFormatter.java27
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/formatter/LogFormatterManager.java69
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/formatter/NullFormatter.java29
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/formatter/TextFormatter.java51
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/formatter/test/LogFormatterManagerTestCase.java37
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/formatter/test/NullFormatterTestCase.java31
-rw-r--r--logserver/src/test/java/com/yahoo/logserver/formatter/test/TextFormatterTestCase.java47
7 files changed, 0 insertions, 291 deletions
diff --git a/logserver/src/main/java/com/yahoo/logserver/formatter/LogFormatter.java b/logserver/src/main/java/com/yahoo/logserver/formatter/LogFormatter.java
deleted file mode 100644
index 03bb7787b65..00000000000
--- a/logserver/src/main/java/com/yahoo/logserver/formatter/LogFormatter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.logserver.formatter;
-
-import com.yahoo.log.LogMessage;
-
-/**
- * This interface is analogous to the java.util.logging.Formatter
- * interface. Classes implementing this interface should be
- * <b>stateless/immutable if possible so formatters can be
- * shared</b>. If it does have state it must not prevent
- * concurrent use.
- *
- * @author Bjorn Borud
- */
-public interface LogFormatter {
- /**
- * Format log message as a string.
- *
- * @param msg The log message
- */
- String format(LogMessage msg);
-
- /**
- * Returns a textual description of the formatter
- */
- String description();
-}
diff --git a/logserver/src/main/java/com/yahoo/logserver/formatter/LogFormatterManager.java b/logserver/src/main/java/com/yahoo/logserver/formatter/LogFormatterManager.java
deleted file mode 100644
index 1d0d29adb9e..00000000000
--- a/logserver/src/main/java/com/yahoo/logserver/formatter/LogFormatterManager.java
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/*
- * $Id$
- *
- */
-
-package com.yahoo.logserver.formatter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * This singleton class implements a central registry of LogFormatter
- * instances.
- *
- * @author Bjorn Borud
- */
-public class LogFormatterManager {
- private static final LogFormatterManager instance;
-
- static {
- instance = new LogFormatterManager();
- instance.addLogFormatterInternal("system.textformatter", new TextFormatter());
- instance.addLogFormatterInternal("system.nullformatter", new NullFormatter());
- }
-
- private final Map<String, LogFormatter> logFormatters = new HashMap<String, LogFormatter>();
-
- private LogFormatterManager() {}
-
- /**
- * LogFormatter lookup function
- *
- * @param name The name of the LogFormatter to be looked up.
- * @return Returns the LogFormatter associated with this name or
- * <code>null</code> if not found.
- */
- public static LogFormatter getLogFormatter(String name) {
- synchronized (instance.logFormatters) {
- return instance.logFormatters.get(name);
- }
- }
-
- /**
- * Get the names of the defined formatters.
- *
- * @return Returns an array containing the names of formatters that
- * have been registered.
- */
- public static String[] getFormatterNames() {
- synchronized (instance.logFormatters) {
- String[] formatterNames = new String[instance.logFormatters.keySet().size()];
- instance.logFormatters.keySet().toArray(formatterNames);
- return formatterNames;
- }
- }
-
- /**
- * Internal method which takes care of the job of adding
- * LogFormatter mappings but doesn't perform any of the checks
- * performed by the public method for adding mappings.
- */
- private void addLogFormatterInternal(String name, LogFormatter logFormatter) {
- synchronized (logFormatters) {
- logFormatters.put(name, logFormatter);
- }
- }
-
-}
diff --git a/logserver/src/main/java/com/yahoo/logserver/formatter/NullFormatter.java b/logserver/src/main/java/com/yahoo/logserver/formatter/NullFormatter.java
deleted file mode 100644
index c419ce21272..00000000000
--- a/logserver/src/main/java/com/yahoo/logserver/formatter/NullFormatter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/*
- * $Id$
- *
- */
-
-package com.yahoo.logserver.formatter;
-
-import com.yahoo.log.LogMessage;
-
-/**
- * This formatter doesn't really format anything. It just
- * calls the LogMessage toString() method. This is kind of
- * pointless and silly, but we include it for symmetry...
- * or completeness....or...whatever.
- *
- * @author Bjorn Borud
- */
-public class NullFormatter implements LogFormatter {
-
- public String format(LogMessage msg) {
- return msg.toString();
- }
-
- public String description() {
- return "Format message in native VESPA format";
- }
-
-}
diff --git a/logserver/src/main/java/com/yahoo/logserver/formatter/TextFormatter.java b/logserver/src/main/java/com/yahoo/logserver/formatter/TextFormatter.java
deleted file mode 100644
index efc4a9898ed..00000000000
--- a/logserver/src/main/java/com/yahoo/logserver/formatter/TextFormatter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/*
- * $Id$
- *
- */
-
-package com.yahoo.logserver.formatter;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import com.yahoo.log.LogMessage;
-
-/**
- * Creates human-readable text representation of log message.
- *
- * @author Bjorn Borud
- */
-public class TextFormatter implements LogFormatter {
- static final SimpleDateFormat dateFormat;
-
- static {
- dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- }
-
- public String format(LogMessage msg) {
- StringBuffer sbuf = new StringBuffer(150);
- sbuf.append(dateFormat.format(new Date(msg.getTime())))
- .append(" ")
- .append(msg.getHost())
- .append(" ")
- .append(msg.getThreadProcess())
- .append(" ")
- .append(msg.getService())
- .append(" ")
- .append(msg.getComponent())
- .append(" ")
- .append(msg.getLevel().toString())
- .append(" ")
- .append(msg.getPayload())
- .append("\n");
-
- return sbuf.toString();
- }
-
- public String description() {
- return "Format log-message as human readable text";
- }
-}
diff --git a/logserver/src/test/java/com/yahoo/logserver/formatter/test/LogFormatterManagerTestCase.java b/logserver/src/test/java/com/yahoo/logserver/formatter/test/LogFormatterManagerTestCase.java
deleted file mode 100644
index ece21fbeca7..00000000000
--- a/logserver/src/test/java/com/yahoo/logserver/formatter/test/LogFormatterManagerTestCase.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/*
- * $Id$
- *
- */
-package com.yahoo.logserver.formatter.test;
-
-import com.yahoo.logserver.formatter.LogFormatter;
-import com.yahoo.logserver.formatter.LogFormatterManager;
-import com.yahoo.logserver.formatter.NullFormatter;
-import com.yahoo.logserver.formatter.TextFormatter;
-
-import org.junit.*;
-
-import static org.junit.Assert.*;
-
-/**
- * Test the LogFormatterManager
- *
- * @author Bjorn Borud
- */
-public class LogFormatterManagerTestCase {
-
- /**
- * Ensure the system formatters are present
- */
- @Test
- public void testSystemFormatters() {
- LogFormatter lf = LogFormatterManager.getLogFormatter("system.textformatter");
- assertNotNull(lf);
- assertEquals(TextFormatter.class, lf.getClass());
-
- lf = LogFormatterManager.getLogFormatter("system.nullformatter");
- assertNotNull(lf);
- assertEquals(NullFormatter.class, lf.getClass());
- }
-}
diff --git a/logserver/src/test/java/com/yahoo/logserver/formatter/test/NullFormatterTestCase.java b/logserver/src/test/java/com/yahoo/logserver/formatter/test/NullFormatterTestCase.java
deleted file mode 100644
index a2582e80754..00000000000
--- a/logserver/src/test/java/com/yahoo/logserver/formatter/test/NullFormatterTestCase.java
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/*
- * $Id$
- *
- */
-package com.yahoo.logserver.formatter.test;
-
-import com.yahoo.log.LogMessage;
-import com.yahoo.logserver.formatter.NullFormatter;
-import com.yahoo.logserver.test.MockLogEntries;
-
-import org.junit.*;
-
-import static org.junit.Assert.*;
-
-/**
- * Test the NullFormatter
- *
- * @author Bjorn Borud
- */
-public class NullFormatterTestCase {
-
- @Test
- public void testNullFormatter() {
- NullFormatter nf = new NullFormatter();
- LogMessage[] ms = MockLogEntries.getMessages();
- for (LogMessage m : ms) {
- assertEquals(m.toString(), nf.format(m));
- }
- }
-}
diff --git a/logserver/src/test/java/com/yahoo/logserver/formatter/test/TextFormatterTestCase.java b/logserver/src/test/java/com/yahoo/logserver/formatter/test/TextFormatterTestCase.java
deleted file mode 100644
index aee3932fa06..00000000000
--- a/logserver/src/test/java/com/yahoo/logserver/formatter/test/TextFormatterTestCase.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/*
- * $Id$
- *
- */
-package com.yahoo.logserver.formatter.test;
-
-import com.yahoo.log.InvalidLogFormatException;
-import com.yahoo.log.LogMessage;
-import com.yahoo.logserver.formatter.TextFormatter;
-import com.yahoo.logserver.test.MockLogEntries;
-
-import org.junit.*;
-
-import static org.junit.Assert.*;
-
-/**
- * Test the TextFormatter
- *
- * @author Bjorn Borud
- */
-public class TextFormatterTestCase {
-
- /**
- * Just simple test to make sure it doesn't die on us
- */
- @Test
- public void testTextFormatter() {
- TextFormatter tf = new TextFormatter();
- LogMessage[] ms = MockLogEntries.getMessages();
- for (int i = 0; i < ms.length; i++) {
- System.out.println(tf.format(ms[i]));
- }
- }
-
- /**
- * Test that a specific log message is formatted correctly
- */
- @Test
- public void testSpecificMessage() throws InvalidLogFormatException {
- String l = "1115200798.195568\texample.yahoo.com\t65819\ttopleveldispatch\tfdispatch.queryperf\tevent\tvalue/1 name=\"query_eval_time_avg_s\" value=0.0229635972697721825";
- String result = "2005-05-04 09:59:58 example.yahoo.com 65819 topleveldispatch fdispatch.queryperf EVENT value/1 name=\"query_eval_time_avg_s\" value=0.0229635972697721825\n";
- LogMessage m = LogMessage.parseNativeFormat(l);
- TextFormatter tf = new TextFormatter();
- assertEquals(result, tf.format(m));
- }
-}