You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2022/01/13 00:33:58 UTC

[logging-log4j2] branch master updated: Add class from version 1.2.17.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/master by this push:
     new e7df95e  Add class from version 1.2.17.
e7df95e is described below

commit e7df95e97e15ea6c6d9c4c4e164bfe7b920dba24
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 12 19:33:13 2022 -0500

    Add class from version 1.2.17.
    
    - Binary compatibility.
    - Parts may be reimplemented later.
    - Some are used in forthcoming tests.
---
 .../main/java/org/apache/log4j/VectorAppender.java | 77 ++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/VectorAppender.java b/log4j-1.2-api/src/main/java/org/apache/log4j/VectorAppender.java
new file mode 100644
index 0000000..c380c34
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/VectorAppender.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.log4j;
+
+import java.util.Vector;
+
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ * An appender that appends logging events to a vector.
+ */
+public class VectorAppender extends AppenderSkeleton {
+
+    public Vector vector;
+
+    public VectorAppender() {
+        vector = new Vector();
+    }
+
+    /**
+     * Does nothing.
+     */
+    @Override
+    public void activateOptions() {
+    }
+
+    /**
+     * This method is called by the {@link AppenderSkeleton#doAppend} method.
+     *
+     */
+    @Override
+    public void append(final LoggingEvent event) {
+        // System.out.println("---Vector appender called with message ["+event.getRenderedMessage()+"].");
+        // System.out.flush();
+        try {
+            Thread.sleep(100);
+        } catch (final Exception e) {
+        }
+        vector.addElement(event);
+    }
+
+    @Override
+    public synchronized void close() {
+        if (this.closed) {
+            return;
+        }
+        this.closed = true;
+    }
+
+    public Vector getVector() {
+        return vector;
+    }
+
+    public boolean isClosed() {
+        return closed;
+    }
+
+    @Override
+    public boolean requiresLayout() {
+        return false;
+    }
+}