<commit_before>/*
 * $Log: LogSender.java,v $
 * Revision 1.5  2007-02-12 14:02:19  europe\L190409
 * Logger from LogUtil
 *
 * Revision 1.4  2006/06/14 09:50:25  <NAME> <<EMAIL>>
 * avoid null pointer exception when prc==null
 *
 * Revision 1.3  2005/12/28 08:38:15  <NAME> <<EMAIL>>
 * corrected typo in attributename
 *
 * Revision 1.2  2005/10/24 09:59:24  <NAME> <<EMAIL>>
 * Add support for pattern parameters, and include them into several listeners,
 * senders and pipes that are file related
 *
 * Revision 1.1  2005/06/20 09:05:38  <NAME> <<EMAIL>>
 * introduction of LogSender
 *
 */
package nl.nn.adapterframework.pipes;

import nl.nn.adapterframework.configuration.ConfigurationException;
import nl.nn.adapterframework.core.ParameterException;
import nl.nn.adapterframework.core.SenderException;
import nl.nn.adapterframework.core.SenderWithParametersBase;
import nl.nn.adapterframework.core.TimeOutException;
import nl.nn.adapterframework.parameters.IParameterHandler;
import nl.nn.adapterframework.parameters.ParameterResolutionContext;
import nl.nn.adapterframework.util.LogUtil;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/**
 * Sender that just logs its message.
 * 
 * <p><b>Configuration:</b>
 * <table border="1">
 * <tr><th>attributes</th><th>description</th><th>default</th></tr>
 * <tr><td>{@link #setLogLevel(String) logLevel}</td><td>level on which messages are logged</td><td>info</td></tr>
 * <tr><td>{@link #setLogCategory(String) logCategory}</td><td>category under which messages are logged</td><td>name of the sender</td></tr>
 * </table>
 * 
 * @author <NAME>
 * @since  4.3
 * @version Id
 */
public class LogSender extends SenderWithParametersBase implements IParameterHandler {
	public static final String version="$RCSfile: LogSender.java,v $ $Revision: 1.5 $ $Date: 2007-02-12 14:02:19 $";
	
	private String logLevel="info";
	private String logCategory=null;

	protected Level level;
	protected Logger log;

	public void configure() throws ConfigurationException {
		super.configure();
		log=LogUtil.getLogger(getLogCategory());
		level=Level.toLevel(getLogLevel());
	}

	public boolean isSynchronous() {
		return false;
	}

	public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
		log.log(level,message);
		
		if (prc != null) {
			try {
				prc.forAllParameters(paramList, this);
			} catch (ParameterException e) {
				throw new SenderException("exception determining value of parameters", e);
			}
		}
		
		return correlationID;<commit_msg>return message instead of correlationid<commit_after>/*
 * $Log: LogSender.java,v $
 * Revision 1.6  2007-09-13 09:09:43  europe\L190409
 * return message instead of correlationid
 *
 * Revision 1.5  2007/02/12 14:02:19  <NAME> <<EMAIL>>
 * Logger from LogUtil
 *
 * Revision 1.4  2006/06/14 09:50:25  <NAME> <<EMAIL>>
 * avoid null pointer exception when prc==null
 *
 * Revision 1.3  2005/12/28 08:38:15  <NAME> <<EMAIL>>
 * corrected typo in attributename
 *
 * Revision 1.2  2005/10/24 09:59:24  <NAME> <<EMAIL>>
 * Add support for pattern parameters, and include them into several listeners,
 * senders and pipes that are file related
 *
 * Revision 1.1  2005/06/20 09:05:38  <NAME> <<EMAIL>>
 * introduction of LogSender
 *
 */
package nl.nn.adapterframework.pipes;

import nl.nn.adapterframework.configuration.ConfigurationException;
import nl.nn.adapterframework.core.ParameterException;
import nl.nn.adapterframework.core.SenderException;
import nl.nn.adapterframework.core.SenderWithParametersBase;
import nl.nn.adapterframework.core.TimeOutException;
import nl.nn.adapterframework.parameters.IParameterHandler;
import nl.nn.adapterframework.parameters.ParameterResolutionContext;
import nl.nn.adapterframework.util.LogUtil;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/**
 * Sender that just logs its message.
 * 
 * <p><b>Configuration:</b>
 * <table border="1">
 * <tr><th>attributes</th><th>description</th><th>default</th></tr>
 * <tr><td>{@link #setLogLevel(String) logLevel}</td><td>level on which messages are logged</td><td>info</td></tr>
 * <tr><td>{@link #setLogCategory(String) logCategory}</td><td>category under which messages are logged</td><td>name of the sender</td></tr>
 * </table>
 * 
 * @author <NAME>
 * @since  4.3
 * @version Id
 */
public class LogSender extends SenderWithParametersBase implements IParameterHandler {
	public static final String version="$RCSfile: LogSender.java,v $ $Revision: 1.6 $ $Date: 2007-09-13 09:09:43 $";
	
	private String logLevel="info";
	private String logCategory=null;

	protected Level level;
	protected Logger log;

	public void configure() throws ConfigurationException {
		super.configure();
		log=LogUtil.getLogger(getLogCategory());
		level=Level.toLevel(getLogLevel());
	}

	public boolean isSynchronous() {
		return true;
	}

	public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
		log.log(level,message);
		
		if (prc != null) {
			try {
				prc.forAllParameters(paramList, this);
			} catch (ParameterException e) {
				throw new SenderException("exception determining value of parameters", e);
			}
		}
		
		return message;
{'fraction_non_alphanumeric': 0.12996658002227998, 'fraction_numerical': 0.04270330486446342, 'mean_word_length': 4.926292629262926, 'pattern_counts': {'":': 0, '<': 90, '<?xml version=': 0, '>': 90, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6811694', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1689, 'n_words': 414}