public void addChild(LogRecordHandler handler){ if(Redwood.depth != 0){ throw new IllegalStateException("Cannot modify Redwood when within a track"); } children.add(new RecordHandlerTree(handler)); } protected void addChildTree(RecordHandlerTree tree){
Redwood.rootHandler().addChild( RedirectOutputHandler.fromJavaUtilLogging(topLogger)); Redwood.log("Hello from Redwood -> Java!");
switch(type){ case SIMPLE: toPassOn = append(toPassOn, toPass); break; case START_TRACK: break; Iterator<RecordHandlerTree> iter = children(); while(iter.hasNext()){ //for each child... RecordHandlerTree child = iter.next(); child.process(r, MessageType.SIMPLE, newDepth, timestamp); case END_TRACK: case SHUTDOWN: child.process(toPass, type, newDepth, timestamp); break; case SIMPLE: break;
switch(type){ case SIMPLE: toPassOn = append(toPassOn, toPass); break; case START_TRACK: break; Iterator<RecordHandlerTree> iter = children(); while(iter.hasNext()){ //for each child... RecordHandlerTree child = iter.next(); child.process(r, MessageType.SIMPLE, newDepth, timestamp); case END_TRACK: case SHUTDOWN: child.process(toPass, type, newDepth, timestamp); break; case SIMPLE: break;
switch(type){ case SIMPLE: toPassOn = append(toPassOn, toPass); break; case START_TRACK: break; Iterator<RecordHandlerTree> iter = children(); while(iter.hasNext()){ //for each child... RecordHandlerTree child = iter.next(); child.process(r, MessageType.SIMPLE, newDepth, timestamp); case END_TRACK: case SHUTDOWN: child.process(toPass, type, newDepth, timestamp); break; case SIMPLE: break;
switch(type){ case SIMPLE: toPassOn = append(toPassOn, toPass); break; case START_TRACK: break; Iterator<RecordHandlerTree> iter = children(); while(iter.hasNext()){ //for each child... RecordHandlerTree child = iter.next(); child.process(r, MessageType.SIMPLE, newDepth, timestamp); case END_TRACK: case SHUTDOWN: child.process(toPass, type, newDepth, timestamp); break; case SIMPLE: break;
Redwood.rootHandler().addChild( RedirectOutputHandler.fromJavaUtilLogging(topLogger)); Redwood.log("Hello from Redwood -> Java!");
private final Iterator<RecordHandlerTree> childrenIter = children(); private final RecordHandlerTree childOnPrix = childrenIter.hasNext() ? childrenIter.next() : null; private Iterator<LogRecordHandler> childIter = childOnPrix == null ? null : childOnPrix.iterator(); private LogRecordHandler lastReturned = null;
Redwood.rootHandler().addChild( RedirectOutputHandler.fromJavaUtilLogging(topLogger)); Redwood.log("Hello from Redwood -> Java!");
private final Iterator<RecordHandlerTree> childrenIter = children(); private final RecordHandlerTree childOnPrix = childrenIter.hasNext() ? childrenIter.next() : null; private Iterator<LogRecordHandler> childIter = childOnPrix == null ? null : childOnPrix.iterator(); private LogRecordHandler lastReturned = null;
private final Iterator<RecordHandlerTree> childrenIter = children(); private final RecordHandlerTree childOnPrix = childrenIter.hasNext() ? childrenIter.next() : null; private Iterator<LogRecordHandler> childIter = childOnPrix == null ? null : childOnPrix.iterator(); private LogRecordHandler lastReturned = null;
Redwood.rootHandler().addChild( RedirectOutputHandler.fromJavaUtilLogging(topLogger)); Redwood.log("Hello from Redwood -> Java!");
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); } }); })); }
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); } }); })); }
public LogRecordHandler removeChild(LogRecordHandler handler){ if(Redwood.depth != 0){ throw new IllegalStateException("Cannot modify Redwood when within a track"); } Iterator<RecordHandlerTree> iter = children(); while(iter.hasNext()){ LogRecordHandler cand = iter.next().head(); if(cand == handler){ iter.remove(); return cand; } } return null; } public RecordHandlerTree find(LogRecordHandler toFind){
public LogRecordHandler removeChild(LogRecordHandler handler){ if(Redwood.depth != 0){ throw new IllegalStateException("Cannot modify Redwood when within a track"); } Iterator<RecordHandlerTree> iter = children(); while(iter.hasNext()){ LogRecordHandler cand = iter.next().head(); if(cand == handler){ iter.remove(); return cand; } } return null; } public RecordHandlerTree find(LogRecordHandler toFind){
public LogRecordHandler removeChild(LogRecordHandler handler){ if(Redwood.depth != 0){ throw new IllegalStateException("Cannot modify Redwood when within a track"); } Iterator<RecordHandlerTree> iter = children(); while(iter.hasNext()){ LogRecordHandler cand = iter.next().head(); if(cand == handler){ iter.remove(); return cand; } } return null; } public RecordHandlerTree find(LogRecordHandler toFind){
@Override public void remove() { if(!seenHead){ throw new IllegalStateException("INTERNAL: this shouldn't happen..."); } if(lastReturned == null){ throw new IllegalStateException("Called remove() before any elements returned"); } if(childOnPrix != null && lastReturned == childOnPrix.head()){ childrenIter.remove(); } else if(childIter != null){ childIter.remove(); } else { throw new IllegalStateException("INTERNAL: not sure what we're removing"); } } };
@Override public void remove() { if(!seenHead){ throw new IllegalStateException("INTERNAL: this shouldn't happen..."); } if(lastReturned == null){ throw new IllegalStateException("Called remove() before any elements returned"); } if(childOnPrix != null && lastReturned == childOnPrix.head()){ childrenIter.remove(); } else if(childIter != null){ childIter.remove(); } else { throw new IllegalStateException("INTERNAL: not sure what we're removing"); } } };