package com.boundary.sdk.event.syslog;


import java.util.Date;

import org.productivity.java.syslog4j.Syslog;
import org.productivity.java.syslog4j.SyslogIF;

/**
 * Class to generate syslog messages for testing
 * 
 * @author davidg
 *
 */
public class SyslogMessageGenerator {
	
	
	private SyslogIF syslog;

	public SyslogMessageGenerator() {
		syslog = Syslog.getInstance("udp");
		syslog.getConfig().setUseStructuredData(false);
		syslog.getConfig().setHost("localhost");
		syslog.getConfig().setFacility(SyslogIF.FACILITY_LOCAL0);
	}
	
	/**
	 * Sets the host on the syslog message
	 * 
	 * @param host
	 */
	public void setHost(String host) {
		syslog.getConfig().setHost(host);
	}
	
	/**
	 * Sets the facility on the syslog message
	 * 
	 * @param facility
	 */
	public void setFacility(int facility) {
		syslog.getConfig().setFacility(facility);
	}
	
	/**
	 * Set the port to send the syslog message
	 * 
	 * @param port
	 */
	public void setPort(int port) {
		syslog.getConfig().setPort(port);
	}
	
	public void sendMessages(int count,int delay) throws InterruptedException {
		for (int n = count ; n != 0 ; n--) {
			
			syslog.info(new Date() + "TESTING------TESTING-----TESTING-----TESTING");
			if (n != count && n % 10 == 0) {
				System.out.println("Sent " + (count - n) + " messages");
			}
			Thread.sleep(delay);
		}
		System.out.println("Sent " + count + " messages");

	}
	
	public static void main(String[] args) throws InterruptedException {
		SyslogMessageGenerator generator = new SyslogMessageGenerator();
		
		generator.sendMessages(100,10);

	}
}

@@ -151,16 +151,121 @@
 yslogIF;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport com.boundary.sdk.event.snmp.SmiSupport;
 %0A%0A/**%0A *
@@ -385,33 +385,281 @@
 %0A%09%0A%09
-%0A%09private SyslogIF syslog
+private static Logger LOG = LoggerFactory.getLogger(SyslogMessageGenerator.class);%0A%09%0A%09private SyslogIF syslog;%0A%09%0A%09private static final int DEFAULT_COUNT=10;%0A%09private static final int DEFAULT_DELAY=10;%0A%09%0A%09private int count = DEFAULT_COUNT;%0A%09private int delay = DEFAULT_DELAY
 ;%0A%0A%09
@@ -883,16 +883,190 @@
 OCAL0);%0A
+%09%09count = DEFAULT_COUNT;%0A%09%09delay = DEFAULT_DELAY;%0A%09%7D%0A%09%0A%09public void setCount(int count) %7B%0A%09%09this.count = count;%0A%09%7D%0A%09%0A%09public void setDelay(int delay) %7B%0A%09%09this.delay = delay;%0A
 %09%7D%0A%09%0A%09/*
@@ -1524,24 +1524,116 @@
 port);%0A%09%7D%0A%09%0A
+%09public void sendMessages() throws InterruptedException %7B%0A%09%09sendMessages(count,delay);%0A%09%7D%0A%09%0A
 %09public void
@@ -1857,34 +1857,24 @@
 ) %7B%0A%09%09%09%09
-System.out.println
+LOG.info
 (%22Sent %22
@@ -1937,16 +1937,165 @@
 y);%0A%09%09%7D%0A
+%09%09LOG.info(%22Sent %22 + count + %22 messages%22);%0A%0A%09%7D%0A%09%0A%09/**%0A%09 * %0A%09 * @param args%0A%09 */%0A%09void handleArguments(String%5B%5D args) %7B%0A%09%09%0A%09%09if (args.length != 3) %7B%0A%09
 %09%09System
@@ -2099,11 +2099,11 @@
 tem.
-out
+err
 .pri
@@ -2112,45 +2112,346 @@
 ln(%22
-Sent %22 + count + %22 messages%22
+usage: %22 + (args.length == 1 ? args%5B0%5D : %22%22) + %22 %3Ccount%3E %3Cdelay%3E%22);%0A%09%09%09System.exit(1);%0A%09%09%7D%0A%09%09%0A%09%09setCount(Integer.parseInt(args%5B1%5D));%0A%09%09setDelay(Integer.parseInt(args%5B2%5D)
 );%0A
+%09%09
 %0A%09%7D%0A%09%0A
+%09/**%0A%09 * Sends syslog messages with the number sent and delayed between each%0A%09 * passed in as arguments%0A%09 * @param args%0A%09 * @throws InterruptedException%0A%09 */%0A
 %09pub
@@ -2516,16 +2516,17 @@
 ption %7B%0A
+%0A
 %09%09Syslog
@@ -2584,16 +2584,51 @@
 ator();%0A
+%09%09generator.handleArguments(args);%0A
 %09%09%0A%09%09gen
@@ -2651,18 +2651,11 @@
 ges(
-100,10
 );%0A
-%0A
 %09%7D%0A%7D

Add ability to pass count of messages to send and the delay between each