1 package net.javacoding.jspider.mod.plugin.console; 2 3 4 import net.javacoding.jspider.mod.plugin.FlatOutputPlugin; 5 import net.javacoding.jspider.core.util.config.PropertySet; 6 import net.javacoding.jspider.core.logging.Log; 7 import net.javacoding.jspider.core.logging.LogFactory; 8 9 10 16 public class ConsolePlugin extends FlatOutputPlugin { 17 18 public static final String MODULE_NAME = "Console writer JSpider module"; 19 public static final String MODULE_VERSION = "v1.0"; 20 public static final String MODULE_DESCRIPTION = "A simple JSpider module that writes down all jobs carried out by the JSpider on your console"; 21 public static final String MODULE_VENDOR = "http://www.javacoding.net"; 22 23 public static final String PREFIX = "prefix"; 24 public static final String ADDSPACE = "addspace"; 25 26 public static final String PREFIX_DEFAULT = "[Plugin] "; 27 28 protected String name; 29 protected String prefix; 30 protected Log log; 31 32 public ConsolePlugin ( String name, PropertySet config ) { 33 log = LogFactory.getLog(ConsolePlugin.class); 34 this.name = name; 35 prefix = config.getString(PREFIX, PREFIX_DEFAULT); 36 log.debug("plugin '" + name + "' prefix is '" + prefix + "'" ); 37 if ( config.getBoolean(ADDSPACE, false)) { 38 prefix = prefix + " "; 39 log.debug("adding space after prefix"); 40 } 41 log.info("Prefix set to '" + prefix + "'"); 42 } 43 44 public ConsolePlugin ( ) { 45 log = LogFactory.getLog(ConsolePlugin.class); 46 prefix = PREFIX_DEFAULT; 47 log.info("Prefix set to default: '" + prefix + "'"); 48 } 49 50 51 public String getName() { 52 return MODULE_NAME; 53 } 54 55 public String getVersion() { 56 return MODULE_VERSION; 57 } 58 59 public String getDescription() { 60 return MODULE_DESCRIPTION; 61 } 62 63 public String getVendor() { 64 return MODULE_VENDOR; 65 } 66 67 protected void println(Object object) { 68 System.out.println(prefix + object); 69 } 70 } 71 | Popular Tags |