001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017package org.apache.logging.log4j.core; 018 019import java.util.Collections; 020import java.util.Map; 021 022import org.apache.logging.log4j.Level; 023import org.apache.logging.log4j.Marker; 024import org.apache.logging.log4j.ThreadContext; 025import org.apache.logging.log4j.ThreadContext.ContextStack; 026import org.apache.logging.log4j.core.impl.ThrowableProxy; 027import org.apache.logging.log4j.message.Message; 028import org.apache.logging.log4j.util.ReadOnlyStringMap; 029 030 031/** 032 * An abstract log event implementation with default values for all methods. The setters are no-ops. 033 */ 034public abstract class AbstractLogEvent implements LogEvent { 035 036 private static final long serialVersionUID = 1L; 037 038 /** 039 * Subclasses should implement this method to provide an immutable version. 040 */ 041 @Override 042 public LogEvent toImmutable() { 043 return this; 044 } 045 046 @Override 047 public ReadOnlyStringMap getContextData() { 048 return null; 049 } 050 051 /** 052 * Returns {@link Collections#emptyMap()}. 053 */ 054 @Override 055 public Map<String, String> getContextMap() { 056 return Collections.emptyMap(); 057 } 058 059 @Override 060 public ContextStack getContextStack() { 061 return ThreadContext.EMPTY_STACK; 062 } 063 064 @Override 065 public Level getLevel() { 066 return null; 067 } 068 069 @Override 070 public String getLoggerFqcn() { 071 return null; 072 } 073 074 @Override 075 public String getLoggerName() { 076 return null; 077 } 078 079 @Override 080 public Marker getMarker() { 081 return null; 082 } 083 084 @Override 085 public Message getMessage() { 086 return null; 087 } 088 089 @Override 090 public StackTraceElement getSource() { 091 return null; 092 } 093 094 @Override 095 public long getThreadId() { 096 return 0; 097 } 098 099 @Override 100 public String getThreadName() { 101 return null; 102 } 103 104 @Override 105 public int getThreadPriority() { 106 return 0; 107 } 108 109 @Override 110 public Throwable getThrown() { 111 return null; 112 } 113 114 @Override 115 public ThrowableProxy getThrownProxy() { 116 return null; 117 } 118 119 @Override 120 public long getTimeMillis() { 121 return 0; 122 } 123 124 @Override 125 public boolean isEndOfBatch() { 126 return false; 127 } 128 129 @Override 130 public boolean isIncludeLocation() { 131 return false; 132 } 133 134 @Override 135 public void setEndOfBatch(final boolean endOfBatch) { 136 // do nothing 137 } 138 139 @Override 140 public void setIncludeLocation(final boolean locationRequired) { 141 // do nothing 142 } 143 144 @Override 145 public long getNanoTime() { 146 return 0; 147 } 148}