<commit_before>package alma.alarmsystem.source;

import java.util.Collection;

import java.util.logging.Logger;

import java.util.Iterator;

import alma.acs.util.XmlNormalizer;

/**
 * ACS implementation of the AlarmSystemInterface.
 * The alarms are published in the logging.
 * 
 * @author acaproni
 *
 */
public class ACSAlarmSystemInterfaceProxy implements ACSAlarmSystemInterface {
	
	// The logger to publish the alarms
	private  Logger m_logger;
	
	// The name of the source
	String name;
	
	/**
	 * The basic constructor
	 * 
	 * @param name The name of the source
	 * @param logger The logger to log alarms in
	 */
	public ACSAlarmSystemInterfaceProxy(String name, Logger logger) {
		if (logger==null) {
			throw new IllegalArgumentException("Invalid null logger in constructor");
		}
		this.name=name;
		m_logger = logger;
		m_logger.fine("Alarm source of "+name+" connected to the logging");
	}
	
	/**
	 * Set the source name.
	 * @param newSourceName the source name.
	 */
	public void setSourceName(String newSourceName) {
		name = newSourceName;
	}
	
	/**
	 * Get the source name.
	 * @return the source name.
	 */
	public String getSourceName() {
		return name;
	}
	
	/**
	 * Close and deallocate resources.
	 */
	public void close() {}
	
	/**
	 * Push a fault state.
	 * @param state the fault state change to push.
	 * @throws ASIException if the fault state can not be pushed.
	 */
	public void push(ACSFaultState state) {
		logFaultState(state);
	}
	
	/**
	 * Push a collection of fault states.
	 * @param states
	 * @throws ASIException if the fault state collection can not be pushed.
	 */
	public void push(Collection states) {
		if (states==null || states.size()==0) {
			return;
		}
		Iterator iterator = states.iterator();

	    while (iterator.hasNext()) {
	      Object next = iterator.next();

	      if (next instanceof ACSFaultState) {
	        push((ACSFaultState) next);
	      } else {
	        throw new IllegalArgumentException("states collection does not contain ACSFaultState instances");
	      }
	    }
	}
	
	/**
	 * Push the set of active fault states.
	 * @param active the active fault states.
	 * @throws ASIException if the fault state active list can not be pushed.
	 */
	public void pushActiveList(Collection active) {
		if (active==null || active.size()==0) {
			return;
		}
	    push(active);
	}
	
	/**
	 * Write the ACSFaultState in the log
	 * 
	 * @param fs The ACSFaultState to log
	 */
	private void logFaultState(ACSFaultState fs) {
		if (fs==null) {
			return;
		}
		StringBuilder sb = new StringBuilder("Alarm sent: <");
		sb.append(fs.getFamily()+','+fs.getMember()+','+fs.getCode()+'>');
		sb.append(" "+fs.getDescriptor());
		m_logger.severe(XmlNormalizer.normalize(sb.toString()));
	}
}
<commit_msg>The level of the messages logged when sending alarm is now Alert (the same as C++)<commit_after>package alma.alarmsystem.source;

import java.util.Collection;

import java.util.logging.Logger;

import java.util.Iterator;

import alma.acs.logging.AcsLogLevel;
import alma.acs.util.XmlNormalizer;

/**
 * ACS implementation of the AlarmSystemInterface.
 * The alarms are published in the logging.
 * 
 * @author acaproni
 *
 */
public class ACSAlarmSystemInterfaceProxy implements ACSAlarmSystemInterface {
	
	// The logger to publish the alarms
	private  Logger m_logger;
	
	// The name of the source
	String name;
	
	/**
	 * The basic constructor
	 * 
	 * @param name The name of the source
	 * @param logger The logger to log alarms in
	 */
	public ACSAlarmSystemInterfaceProxy(String name, Logger logger) {
		if (logger==null) {
			throw new IllegalArgumentException("Invalid null logger in constructor");
		}
		this.name=name;
		m_logger = logger;
		m_logger.fine("Alarm source of "+name+" connected to the logging");
	}
	
	/**
	 * Set the source name.
	 * @param newSourceName the source name.
	 */
	public void setSourceName(String newSourceName) {
		name = newSourceName;
	}
	
	/**
	 * Get the source name.
	 * @return the source name.
	 */
	public String getSourceName() {
		return name;
	}
	
	/**
	 * Close and deallocate resources.
	 */
	public void close() {}
	
	/**
	 * Push a fault state.
	 * @param state the fault state change to push.
	 * @throws ASIException if the fault state can not be pushed.
	 */
	public void push(ACSFaultState state) {
		logFaultState(state);
	}
	
	/**
	 * Push a collection of fault states.
	 * @param states
	 * @throws ASIException if the fault state collection can not be pushed.
	 */
	public void push(Collection states) {
		if (states==null || states.size()==0) {
			return;
		}
		Iterator iterator = states.iterator();

	    while (iterator.hasNext()) {
	      Object next = iterator.next();

	      if (next instanceof ACSFaultState) {
	        push((ACSFaultState) next);
	      } else {
	        throw new IllegalArgumentException("states collection does not contain ACSFaultState instances");
	      }
	    }
	}
	
	/**
	 * Push the set of active fault states.
	 * @param active the active fault states.
	 * @throws ASIException if the fault state active list can not be pushed.
	 */
	public void pushActiveList(Collection active) {
		if (active==null || active.size()==0) {
			return;
		}
	    push(active);
	}
	
	/**
	 * Write the ACSFaultState in the log
	 * 
	 * @param fs The ACSFaultState to log
	 */
	private void logFaultState(ACSFaultState fs) {
		if (fs==null) {
			return;
		}
		StringBuilder sb = new StringBuilder("Alarm sent: <");
		sb.append(fs.getFamily()+','+fs.getMember()+','+fs.getCode()+'>');
		sb.append(" "+fs.getDescriptor());
		m_logger.log(AcsLogLevel.ALERT,XmlNormalizer.normalize(sb.toString()));
	}
}

{'fraction_non_alphanumeric': 0.11420464621386771, 'fraction_numerical': 0.0007093456286575634, 'mean_word_length': 3.2922374429223744, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3145610', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1665, 'n_words': 543}