/** * Add handlers to Redwood. This is the main way to tell Redwood to do stuff. * Use this by calling a combination of methods in Handlers. It may be useful * to "import static RedwoodConfiguration.Handlers.*" * * For example: * <pre> * handlers(branch( * chain( hideDebug, collapseApproximate, branch( output, file("stderr.log") ), * chain( showOnlyError, file("err.log") ). * chain( showOnlyChannels("results", "evaluate"), file("results.log") ), * chain( file("redwood.log") ), * noop)) * </pre> * * @param paths A number of paths to add. * @return this */ public RedwoodConfiguration handlers(Thunk... paths) { for (final Thunk thunk : paths) { tasks.add(() -> thunk.apply(RedwoodConfiguration.this, Redwood.rootHandler())); } return this; }
/** * Add handlers to Redwood. This is the main way to tell Redwood to do stuff. * Use this by calling a combination of methods in Handlers. It may be useful * to "import static RedwoodConfiguration.Handlers.*" * * For example: * <pre> * handlers(branch( * chain( hideDebug, collapseApproximate, branch( output, file("stderr.log") ), * chain( showOnlyError, file("err.log") ). * chain( showOnlyChannels("results", "evaluate"), file("results.log") ), * chain( file("redwood.log") ), * noop)) * </pre> * * @param paths A number of paths to add. * @return this */ public RedwoodConfiguration handlers(Thunk... paths) { for (final Thunk thunk : paths) { tasks.add(() -> thunk.apply(RedwoodConfiguration.this, Redwood.rootHandler())); } return this; }
/** * Add handlers to Redwood. This is the main way to tell Redwood to do stuff. * Use this by calling a combination of methods in Handlers. It may be useful * to "import static RedwoodConfiguration.Handlers.*" * * For example: * <pre> * handlers(branch( * chain( hideDebug, collapseApproximate, branch( output, file("stderr.log") ), * chain( showOnlyError, file("err.log") ). * chain( showOnlyChannels("results", "evaluate"), file("results.log") ), * chain( file("redwood.log") ), * noop)) * </pre> * * @param paths A number of paths to add. * @return this */ public RedwoodConfiguration handlers(Thunk... paths) { for (final Thunk thunk : paths) { tasks.add(() -> thunk.apply(RedwoodConfiguration.this, Redwood.rootHandler())); } return this; }
@Override public void run() { thunk.apply(RedwoodConfiguration.this, Redwood.rootHandler()); } });
@Override public void apply(RedwoodConfiguration config, Redwood.RecordHandlerTree root) { for (Thunk destination : destinations) { destination.apply(config, root); } } };
private Redwood.RecordHandlerTree buildChain(RedwoodConfiguration config, LogRecordHandler[] handlers, int i) { Redwood.RecordHandlerTree rtn = new Redwood.RecordHandlerTree(handlers[i]); if (i < handlers.length - 1) { rtn.addChildTree( buildChain(config, handlers, i + 1) ); } else { destination.apply(config, rtn); } return rtn; } @Override
@Override public void apply(RedwoodConfiguration config, Redwood.RecordHandlerTree root) { if (handlers.length == 0) { destination.apply(config, root); } else { root.addChildTree(buildChain(config, handlers, 0)); } } };
@Override public void apply(RedwoodConfiguration config, Redwood.RecordHandlerTree root) { if (handlers.length == 0) { destination.apply(config, root); } else { root.addChildTree(buildChain(config, handlers, 0)); } } };
/** * Send any incoming messages multiple ways. * For example, you may want to send the same output to console and a file. * @param destinations The destinations for log messages coming into this node. */ public static Thunk branch(final Thunk... destinations) { return (config, root) -> { for (Thunk destination : destinations) { destination.apply(config, root); } }; }
private Redwood.RecordHandlerTree buildChain(RedwoodConfiguration config, LogRecordHandler[] handlers, int i) { Redwood.RecordHandlerTree rtn = new Redwood.RecordHandlerTree(handlers[i]); if (i < handlers.length - 1) { rtn.addChildTree( buildChain(config, handlers, i + 1) ); } else { destination.apply(config, rtn); } return rtn; } @Override
/** * Send any incoming messages multiple ways. * For example, you may want to send the same output to console and a file. * @param destinations The destinations for log messages coming into this node. */ public static Thunk branch(final Thunk... destinations) { return (config, root) -> { for (Thunk destination : destinations) { destination.apply(config, root); } }; }
private Redwood.RecordHandlerTree buildChain(RedwoodConfiguration config, LogRecordHandler[] handlers, int i) { Redwood.RecordHandlerTree rtn = new Redwood.RecordHandlerTree(handlers[i]); if (i < handlers.length - 1) { rtn.addChildTree( buildChain(config, handlers, i + 1) ); } else { destination.apply(config, rtn); } return rtn; } @Override
@Override public void apply(RedwoodConfiguration config, Redwood.RecordHandlerTree root) { if (handlers.length == 0) { destination.apply(config, root); } else { root.addChildTree(buildChain(config, handlers, 0)); } } };
/** * Send any incoming messages multiple ways. * For example, you may want to send the same output to console and a file. * @param destinations The destinations for log messages coming into this node. */ public static Thunk branch(final Thunk... destinations) { return (config, root) -> { for (Thunk destination : destinations) { destination.apply(config, root); } }; }
private Redwood.RecordHandlerTree buildChain(RedwoodConfiguration config, LogRecordHandler[] handlers, int i) { Redwood.RecordHandlerTree rtn = new Redwood.RecordHandlerTree(handlers[i]); if (i < handlers.length - 1) { rtn.addChildTree( buildChain(config, handlers, i + 1) ); } else { destination.apply(config, rtn); } return rtn; } @Override
@Override public void apply(RedwoodConfiguration config, Redwood.RecordHandlerTree root) { if (handlers.length == 0) { destination.apply(config, root); } else { root.addChildTree(buildChain(config, handlers, 0)); } } };