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.camel.model; 018 019import javax.xml.bind.annotation.XmlAccessType; 020import javax.xml.bind.annotation.XmlAccessorType; 021import javax.xml.bind.annotation.XmlAttribute; 022import javax.xml.bind.annotation.XmlRootElement; 023import javax.xml.bind.annotation.XmlTransient; 024 025import org.apache.camel.spi.Metadata; 026import org.slf4j.Logger; 027 028/** 029 * Logs the defined message to the logger 030 */ 031@Metadata(label = "eip,configuration") 032@XmlRootElement(name = "log") 033@XmlAccessorType(XmlAccessType.FIELD) 034public class LogDefinition extends NoOutputDefinition<LogDefinition> { 035 036 @XmlAttribute(required = true) 037 private String message; 038 @XmlAttribute 039 @Metadata(defaultValue = "INFO", enums = "TRACE,DEBUG,INFO,WARN,ERROR,OFF") 040 private String loggingLevel; 041 @XmlAttribute 042 private String logName; 043 @XmlAttribute 044 private String marker; 045 @XmlAttribute 046 private String loggerRef; 047 @XmlTransient 048 private Logger logger; 049 050 public LogDefinition() { 051 } 052 053 public LogDefinition(String message) { 054 this(); 055 this.message = message; 056 } 057 058 @Override 059 public String toString() { 060 return "Log[" + message + "]"; 061 } 062 063 @Override 064 public String getShortName() { 065 return "log"; 066 } 067 068 @Override 069 public String getLabel() { 070 return "log"; 071 } 072 073 public String getLoggingLevel() { 074 return loggingLevel; 075 } 076 077 /** 078 * Sets the logging level. 079 * <p/> 080 * The default value is INFO 081 */ 082 public void setLoggingLevel(String loggingLevel) { 083 this.loggingLevel = loggingLevel; 084 } 085 086 public String getMessage() { 087 return message; 088 } 089 090 /** 091 * Sets the log message (uses simple language) 092 */ 093 public void setMessage(String message) { 094 this.message = message; 095 } 096 097 public String getLogName() { 098 return logName; 099 } 100 101 /** 102 * Sets the name of the logger 103 */ 104 public void setLogName(String logName) { 105 this.logName = logName; 106 } 107 108 public String getMarker() { 109 return marker; 110 } 111 112 /** 113 * To use slf4j marker 114 */ 115 public void setMarker(String marker) { 116 this.marker = marker; 117 } 118 119 public String getLoggerRef() { 120 return loggerRef; 121 } 122 123 /** 124 * To refer to a custom logger instance to lookup from the registry. 125 */ 126 public void setLoggerRef(String loggerRef) { 127 this.loggerRef = loggerRef; 128 } 129 130 public Logger getLogger() { 131 return logger; 132 } 133 134 /** 135 * To use a custom logger instance 136 */ 137 public void setLogger(Logger logger) { 138 this.logger = logger; 139 } 140 141}