"Fossies" - the Fresh Open Source Software Archive 
Member "apache-log4j-2.12.4-src/log4j-core/src/test/resources/customplugin/FixedStringLayout.java.source" (20 Dec 2021, 1974 Bytes) of package /linux/misc/apache-log4j-2.12.4-src.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache license, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the license for the specific language governing permissions and
15 * limitations under the license.
16 */
17
18 package customplugin;
19
20 import java.util.Collections;
21 import java.util.Map;
22
23 import org.apache.logging.log4j.core.LogEvent;
24 import org.apache.logging.log4j.core.config.plugins.Plugin;
25 import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
26 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
27 import org.apache.logging.log4j.core.layout.AbstractStringLayout;
28
29 @Plugin(name = "FixedString", category = "Core", elementType = "layout", printObject = true)
30 public class FixedStringLayout extends AbstractStringLayout {
31
32 private String fixedString;
33
34 @PluginFactory
35 public static FixedStringLayout createLayout(
36 @PluginAttribute("fixedString") final String fixedString) {
37 return new FixedStringLayout(fixedString);
38 }
39
40 public FixedStringLayout(String fixedString) {
41 super(null, null, null);
42 this.fixedString = fixedString;
43 }
44
45 @Override
46 public String toSerializable(LogEvent event) {
47 return fixedString;
48 }
49
50 @Override
51 public Map<String, String> getContentFormat() {
52 return Collections.emptyMap();
53 }
54 }