/** * Helper method to start a track on the FORCE channel. * @param name The track name to print */ public static void forceTrack(Object name) { startTrack(FORCE, name); }
/** * Helper method to start an anonymous track on the FORCE channel. */ public static void forceTrack() { startTrack(FORCE, ""); }
public static void forceTrack(String title){ Redwood.startTrack(FORCE, title); } public static void endTrack(String check){ Redwood.endTrack(check); }
public static void startTrack(Object...objs){ Redwood.startTrack(objs); } public static void forceTrack(String title){ Redwood.startTrack(FORCE, title); }
/** * Start a multithreaded logging environment. Log messages will be real time * from one of the threads; as each thread finishes, another thread begins logging, * first by making up the backlog, and then by printing any new log messages. * A thread signals that it has finished logging with the finishThread() function; * the multithreaded environment is ended with the endThreads() function. * * @param title The name of the thread group being started */ public static void startThreads(String title){ if(isThreaded){ throw new IllegalStateException("Cannot nest Redwood threaded environments"); } startTrack(FORCE,"Threads( "+title+" )"); isThreaded = true; }
/** * {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public void prettyLog(RedwoodChannels channels, String description) { Redwood.startTrack(description); // sort keys by class name List<Class> sortedKeys = new ArrayList<>(this.keySet()); sortedKeys.sort(Comparator.comparing(Class::getCanonicalName)); // log key/value pairs for (Class key : sortedKeys) { String keyName = key.getCanonicalName().replace("class ", ""); Object value = this.get(key); if (PrettyLogger.dispatchable(value)) { PrettyLogger.log(channels, keyName, value); } else { channels.logf("%s = %s", keyName, value); } } Redwood.endTrack(description); }
if (args.length > 0 && args[0].equals("redwood")) { Redwood.log(Redwood.DBG, "at the top"); Redwood.startTrack("Adaptor test controlled by redwood"); Redwood.log("Hello from Redwood -> Java again!"); logger.log(Level.INFO, "Hello again from the class logger"); Redwood.startTrack("a track"); Redwood.log("Inside a track"); logger.log(Level.INFO, "Hello a third time from the class logger");
private static <K, V> void log(RedwoodChannels channels, String description, Map<K, V> mapping) { Redwood.startTrack(description); if (mapping == null) { channels.log("(mapping is null)"); log(channels, key.toString(), value); } else if (dispatchable(key) || dispatchable(value)) { Redwood.startTrack("Entry " + entryCounter); if (dispatchable(key)) { log(channels, "Key", key);
private static <T> void log(RedwoodChannels channels, String description, T[] array) { Redwood.startTrack(description); if (array == null) { channels.log("(array is null)"); } else if (array.length == 0) { channels.log("(empty)"); } else { int index = 0; for (T item : array) { if (dispatchable(item)) { log(channels, "Index " + index, item); } else { channels.logf("Index %d: %s", index, item); } index++; } } Redwood.endTrack(description); }
private static <T> void log(RedwoodChannels channels, String description, Iterable<T> iterable) { Redwood.startTrack(description); if (iterable == null) { channels.log("(iterable is null)"); } else { int index = 0; for (T item : iterable) { if (dispatchable(item) && item != iterable) { log(channels, "Index " + index, item); } else { channels.logf("Index %d: %s", index, item == iterable ? "...<infinite loop>" : item); } index++; } if (index == 0) { channels.log("(empty)"); } } Redwood.endTrack(description); }
final int fI = i; tasks.add(() -> { startTrack("Runnable " + fI); log(Thread.currentThread().getId()); log("message " + fI + ".1"); startTrack("Wrapper"); for(int i=0; i<100; i++){ Util.threadAndRun(tasks, 100); startTrack("Hidden"); startTrack("Subhidden"); endTrack("Subhidden"); endTrack("Hidden"); startTrack(FORCE, "Shown"); startTrack(FORCE,"Subshown"); endTrack("Subshown"); endTrack("Shown"); log("^shown should have appeared above"); startTrack("Track 1.1"); log(WARN, "some", "something in 1.1"); log("some",ERR,"something in 1.1"); logf("format string %s then int %d", "hello", 7); endTrack("Track 1.1"); startTrack(); log("In an anonymous track"); endTrack();
/** * Helper method to start an anonymous track on the FORCE channel. */ public static void forceTrack() { startTrack(FORCE, ""); }
/** * Helper method to start an anonymous track on the FORCE channel. */ public static void forceTrack() { startTrack(FORCE, ""); }
/** * Helper method to start a track on the FORCE channel. * @param name The track name to print */ public static void forceTrack(Object name) { startTrack(FORCE, name); }
/** * Helper method to start a track on the FORCE channel. * @param name The track name to print */ public static void forceTrack(Object name) { startTrack(FORCE, name); }
/** * Helper method to start a track on the FORCE channel. * @param name The track name to print */ public static void forceTrack(Object name) { startTrack(FORCE, name); }
/** * Helper method to start an anonymous track on the FORCE channel. */ public static void forceTrack() { startTrack(FORCE, ""); }
public static void forceTrack(String title){ Redwood.startTrack(FORCE, title); } public static void endTrack(String check){ Redwood.endTrack(check); }
/** * Start a multithreaded logging environment. Log messages will be real time * from one of the threads; as each thread finishes, another thread begins logging, * first by making up the backlog, and then by printing any new log messages. * A thread signals that it has finished logging with the finishThread() function; * the multithreaded environment is ended with the endThreads() function. * * @param title The name of the thread group being started */ public static void startThreads(String title){ if(isThreaded){ throw new IllegalStateException("Cannot nest Redwood threaded environments"); } startTrack(FORCE,"Threads( "+title+" )"); isThreaded = true; }
@Override public void run() { startTrack("Thread " + theI + " (" + Thread.currentThread().getId() + ")"); for(int time=0; time<5; time++){ log("tick " + time + " from " + theI + " (" + Thread.currentThread().getId() + ")"); try { Thread.sleep(50); } catch (Exception e) {} } endTrack("Thread " + theI + " (" + Thread.currentThread().getId() + ")"); finishThread(); } });