RedwoodConfiguration config = new RedwoodConfiguration().clear(); Set<String> used = Generics.newHashSet(); if(get(props,"log.captureStreams","false",used).equalsIgnoreCase("true")){ config = config.capture(System.out).capture(System.err); if(get(props,"log.captureStdout","false",used).equalsIgnoreCase("true")){ config = config.capture(System.out); if(get(props,"log.captureStderr","false",used).equalsIgnoreCase("true")){ config = config.capture(System.err); String collapse = get(props, "log.collapse", "none", used); List<LogRecordHandler> chain = new LinkedList<>(); if (collapse.equalsIgnoreCase("exact")) { boolean debug = Boolean.parseBoolean(get(props, "log.channels.debug", "true", used)); if (!debug) { chain.add(Handlers.hideDebug); config.channelWidth( Integer.parseInt(get(props, "log.channels.width", "0", used)) ); if(get(props,"log.neatExit","false",used).equalsIgnoreCase("true")){ config = config.neatExit(); String outputFile = get(props, "log.file", null, used); if (outputFile != null) { config.defaultFile = new File(outputFile); config = config.handlers(Handlers.defaultFile);
public static void main(String[] args) throws IOException { RedwoodConfiguration.standard().apply(); // Disable SLF4J crap. ArgumentParser.fillOptions(KBPTokensregexExtractor.class, args); KBPTokensregexExtractor extractor = new KBPTokensregexExtractor(DIR); List<Pair<KBPInput, String>> testExamples = KBPRelationExtractor.readDataset(TEST_FILE); extractor.computeAccuracy(testExamples.stream(), PREDICTIONS.map(x -> { try { return "stdout".equalsIgnoreCase(x) ? System.out : new PrintStream(new FileOutputStream(x)); } catch (IOException e) { throw new RuntimeIOException(e); } })); }
/** * An empty Redwood configuration. * Note that without a Console Handler, Redwood will not print anything * @return An empty Redwood Configuration object. */ public static RedwoodConfiguration empty(){ return new RedwoodConfiguration().clear(); }
public static void setVerbose(boolean verbose) { if (verbose) { RedwoodConfiguration.debugLevel().apply(); } else { RedwoodConfiguration.errorLevel().apply(); } }
/** * A standard Redwood configuration, which prints to the console with channels. * It does not show debug level messages (but shows warning and error messages). * This is the usual starting point for new configurations. * @return A basic Redwood Configuration. */ public static RedwoodConfiguration standard() { return new RedwoodConfiguration().clear().handlers( Handlers.chain(Handlers.hideDebug, Handlers.stderr)); }
public static void main(String[] args){ RedwoodConfiguration.current().listenOnChannels(record -> System.out.println(">>> " + record.content), Redwood.ERR).apply(); Redwood.log("hello world!"); Redwood.log(Redwood.ERR, "an error!"); endTrack("Hidden Subtracks"); RedwoodConfiguration.standard().apply(); RedwoodConfiguration.current().neatExit().apply(); startTrack("I should close"); log(FORCE,"so I'm nonempty...");
public void initLog(File logFilePath) throws IOException { RedwoodConfiguration.empty() .handlers(RedwoodConfiguration.Handlers.chain( RedwoodConfiguration.Handlers.showAllChannels(), RedwoodConfiguration.Handlers.stderr), RedwoodConfiguration.Handlers.file(logFilePath.toString()) ).apply(); // fh.setFormatter(new NewlineLogFormatter()); System.out.println("Starting Ssurgeon log, at "+logFilePath.getAbsolutePath()+" date=" + DateFormat.getDateInstance(DateFormat.FULL).format(new Date())); log.info("Starting Ssurgeon log, date=" + DateFormat.getDateInstance(DateFormat.FULL).format(new Date())); }
public static void minimalSetup(){ Properties props = new Properties(); props.setProperty("log.output", "stderr"); RedwoodConfiguration.apply(props); }
/** * The current Redwood configuration; this is used to make incremental changes * to an existing custom configuration. * @return The current Redwood configuration. */ public static RedwoodConfiguration current(){ return new RedwoodConfiguration(); }
public RedwoodConfiguration listenOnChannels(Consumer<Redwood.Record> listener, Object... channels) { return this.handlers( Handlers.chain(new FilterHandler(Collections.singletonList(new LogFilter() { Set<Object> matchAgainst = new HashSet<>(Arrays.asList(channels)); @Override public boolean matches(Redwood.Record message) { for (Object channel : message.channels()) { if (matchAgainst.contains(channel)) { return true; } } return false; } }), true), (config, root) -> { root.addChild(new LogRecordHandler() { @Override public List<Redwood.Record> handle(Redwood.Record record) { listener.accept(record); return Collections.singletonList(record); } }); })); }
/** * The default Redwood configuration, which prints to the console without channels. * It does not show debug level messages (but shows warning and error messages). * This is the usual starting point for new configurations. * @return A basic Redwood Configuration. */ public static RedwoodConfiguration minimal() { return new RedwoodConfiguration().clear().handlers( Handlers.chain(Handlers.hideChannels(), Handlers.hideDebug, Handlers.stderr) ); }
public static void main(String[] args){ RedwoodConfiguration.current().listenOnChannels(record -> { System.out.println(">>> " + record.content.toString()); }, Redwood.ERR).apply(); Redwood.log("hello world!"); Redwood.log(Redwood.ERR, "an error!"); endTrack("Hidden Subtracks"); RedwoodConfiguration.standard().apply(); RedwoodConfiguration.current().neatExit().apply(); startTrack("I should close"); log(FORCE,"so I'm nonempty...");
/** * An empty Redwood configuration. * Note that without a Console Handler, Redwood will not print anything * @return An empty Redwood Configuration object. */ public static RedwoodConfiguration empty(){ return new RedwoodConfiguration().clear(); }
/** * Configures the Redwood logger using a reasonable set of defaults, * which can be overruled by the supplied Properties file. * * @param props The properties file to overrule or augment the default configuration */ public static void apply(Properties props){ //--Tweak Properties //(output to stderr) if (props.getProperty("log.output") == null) { props.setProperty("log.output", "stderr"); } //(capture system streams) if (props.getProperty("log.captureStderr") == null) { props.setProperty("log.captureStderr", "true"); } //(apply properties) RedwoodConfiguration.apply(props); //--Strange Tweaks //(adapt legacy logging systems) JavaUtilLoggingAdaptor.adapt(); }
public static void setVerbose(boolean verbose) { if (verbose) { RedwoodConfiguration.debugLevel().apply(); } else { RedwoodConfiguration.errorLevel().apply(); } }
/** * The current Redwood configuration; this is used to make incremental changes * to an existing custom configuration. * @return The current Redwood configuration. */ public static RedwoodConfiguration current(){ return new RedwoodConfiguration(); }