You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ca...@apache.org on 2010/05/30 05:12:53 UTC
svn commit: r949462 - in
/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api: ./
src/main/java/org/apache/logging/core/
Author: carnold
Date: Sun May 30 03:12:53 2010
New Revision: 949462
URL: http://svn.apache.org/viewvc?rev=949462&view=rev
Log:
Some quick fleshing out of Filter/Destination/Appender and Logger
Added:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/log4j2-api-carnold.iml
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Appender.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Destination.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Filter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Logger.java
Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/log4j2-api-carnold.iml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/log4j2-api-carnold.iml?rev=949462&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/log4j2-api-carnold.iml (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/log4j2-api-carnold.iml Sun May 30 03:12:53 2010
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
+ <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module>
+
Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Appender.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Appender.java?rev=949462&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Appender.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Appender.java Sun May 30 03:12:53 2010
@@ -0,0 +1,73 @@
+package org.apache.logging.core;
+
+/*
+* 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.
+*/
+
+
+/**
+ * @doubt I've thrashing whether this should be an interface
+ * or an immutable composite of simpler parts. The immutable
+ * make a switch cleaner since a replacement of an appender
+ * gives you an opportunity to reevaluate any calculated threadholds.
+ *
+ * This would be the core internal appender, specific API's could offer
+ * what appear to be mutable appenders.
+ */
+public final class Appender {
+ private final Filter filter;
+ private final Destination destination;
+
+ public Appender(final Filter filter, final Destination destination) {
+ if (filter == null || destination == null)
+ {
+ throw new NullPointerException();
+ }
+ this.filter = filter;
+ this.destination = destination;
+ }
+ /**
+ *
+ * Gets the filter associated with this appender.
+ *
+ * @doubt my expectation is that it would be better to not provide
+ * a setter and make Appender immutable. To change a filter,
+ * you would construct a new appender and then swap.
+ *
+ * @return filter, may not be null by can be an instance of a PassAllFilter.
+ */
+ public Filter getFilter()
+ {
+ return filter;
+ }
+
+ /**
+ *
+ * Gets the destination associated with this appender. The destination
+ * would be what would distinguish an "FileAppender" from a "NetworkAppender".
+ *
+ * @doubt not set on the name, had thought of Transport, Channel, EventSink, etc.
+ *
+ *
+ * @return destination, may not be null but may be an instance of a NullDestination.
+ */
+ public Destination getDestination()
+ {
+ return destination;
+ }
+
+
+}
Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Destination.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Destination.java?rev=949462&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Destination.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Destination.java Sun May 30 03:12:53 2010
@@ -0,0 +1,42 @@
+package org.apache.logging.core;
+
+/*
+* 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.
+*/
+
+/**
+ * Implementation of a log destination such as a file, network transport,
+ * database table, etc.
+ *
+ * Implementation should be thread-safe, would be mutable.
+ */
+public interface Destination {
+ /**
+ * Appends a logging event to the destination either synchronously (in which case
+ * it returns null) or asynchronous in which case it returns a Runnable to be executed.
+ *
+ * @param record logging record, may not be null.
+ * @return a runnable to complete the append, or null if the action was completed.
+ */
+ Runnable append(LogEvent record) throws LoggingException;
+
+ /**
+ * Closes the destination.
+ * @return a runnable to complete the close, or null if the close was completed.
+ */
+ Runnable close() throws LoggingException;
+
+}
Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Filter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Filter.java?rev=949462&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Filter.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Filter.java Sun May 30 03:12:53 2010
@@ -0,0 +1,68 @@
+package org.apache.logging.core;
+
+/*
+* 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.
+*/
+
+/**
+ * This interface is used for any object that can determine
+ * to accept or reject a logging request.
+ *
+ * Classes implementing this interface should be immutable
+ * and thread-safe.
+ *
+ * Filter "chains" are a specific implementation of this class.
+ *
+ */
+public interface Filter {
+
+ /**
+ * Potential results of filter evaluation.
+ *
+ * INDETERMINANT is used when a call does not have enough
+ * information to make a determination, such as when calling
+ * the eventless decide call with a filter that does depend on the event
+ * for a determination.
+ */
+ enum Result { DENY, PASS, NEUTRAL, INDETERMINANT};
+
+ Result filter(int level);
+ Result filter(Level level);
+ Result filter(Level level, Object userContext);
+ Result filter(Level level, Object userContext, Object message);
+
+ /**
+ * Evaluate filter for event.
+ * @param event event, may not be null.
+ * @return result of evaluation, may not be INDETERMINANT.
+ */
+ Result filter(LogEvent event);
+
+ /**
+ * Level value below which filter will always return DENY.
+ * Set to Integer.MIN_VALUE if does not consider level.
+ * This method allows for level calculus to determine composite threshold.
+ * @return lowest level that could result in something other than DENY.
+ */
+ int GetLowerLimit();
+ /**
+ * Level value above which filter will always return PASS.
+ * Set to Integer.MAX_VALUE if does not consider level.
+ * This method allows for level calculus to determine composite threshold.
+ * @return highest level that could result in something other than PASS.
+ */
+ int GetUpperLimit();
+}
Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Logger.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Logger.java?rev=949462&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Logger.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/carnold/log4j2-api/src/main/java/org/apache/logging/core/Logger.java Sun May 30 03:12:53 2010
@@ -0,0 +1,40 @@
+package org.apache.logging.core;
+
+/*
+* 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.
+*/
+
+
+/**
+ * As written, this is how an appender or destination sees the Logger (which could be
+ * a java.util.logger, org.apache.log4j.Logger or something else). It may not be how
+ * the client sees a logger.
+ *
+ */
+public interface Logger {
+ String getName();
+
+ /**
+ * This would encapsulate all the thresholds and filters attached to the appender.
+ *
+ * @return filter, may not be null, but may be a DenyAll or AcceptAll filter.
+ */
+ Filter getFilter();
+
+
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org