From: Mathieu Desnoyers Date: Thu, 22 Oct 2015 21:26:25 +0000 (-0400) Subject: Fix: Filer -> Filter typo in example X-Git-Url: http://git.efficios.com/?p=deliverable%2Flttng-ust.git;a=commitdiff_plain;h=a3454bfd4ce4e394b460b83f20ce5ac85ce09056 Fix: Filer -> Filter typo in example Signed-off-by: Mathieu Desnoyers --- diff --git a/doc/examples/java-jul/FilerChangeListenerExample.java b/doc/examples/java-jul/FilerChangeListenerExample.java deleted file mode 100644 index 7e1ab5cd..00000000 --- a/doc/examples/java-jul/FilerChangeListenerExample.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2015 - EfficiOS Inc., Alexandre Montplaisir - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -import java.io.IOException; -import java.util.logging.Level; - -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.filter.FilterChangeNotifier; -import org.lttng.ust.agent.filter.IFilterChangeListener; -import org.lttng.ust.agent.jul.LttngLogHandler; -import org.lttng.ust.agent.session.EventRule; -import org.lttng.ust.agent.session.LogLevelSelector; - -/** - * Example usage of a {@link IFilterChangeListener}. - * - * This listener will simply print to stdout the notifications it receives. To - * try it, run the program, then issue "lttng enable-event" and - * "lttng disable-event" commands for the JUL domain. - * - * @author Alexandre Montplaisir - */ -public class FilerChangeListenerExample { - - private static class ExampleFilterChangeListener implements IFilterChangeListener { - - @Override - public void eventRuleAdded(EventRule rule) { - System.out.println(); - System.out.println("New event rule enabled:"); - System.out.println("Event name: " + rule.getEventName()); - System.out.println(printLogLevel(rule.getLogLevelSelector())); - System.out.println("Filter string: " + rule.getFilterString()); - } - - @Override - public void eventRuleRemoved(EventRule rule) { - System.out.println(); - System.out.println("Event rule disabled:"); - System.out.println("Event name: " + rule.getEventName()); - System.out.println(printLogLevel(rule.getLogLevelSelector())); - System.out.println("Filter string: " + rule.getFilterString()); - } - - /** - * Convenience method to print integer log level values into their JUL - * equivalent. - */ - private static String printLogLevel(LogLevelSelector lls) { - String llname = Level.parse(String.valueOf(lls.getLogLevel())).getName(); - return "Log level: " + llname + ", filter type: " + lls.getLogLevelType().toString(); - } - } - - /** - * Run the program. - * - * @param args - * Command-line arguments (not used) - * @throws IOException - */ - public static void main(String args[]) throws IOException { - /* We need at least one log handler to activate the LTTng agent */ - ILttngHandler handler = new LttngLogHandler(); - - /* Create a listener and register it to the manager */ - IFilterChangeListener listener = new ExampleFilterChangeListener(); - FilterChangeNotifier.getInstance().registerListener(listener); - - System.out.println("Press Enter to finish."); - System.in.read(); - - /* Unregister the listener */ - FilterChangeNotifier.getInstance().unregisterListener(listener); - - /* Cleanup the log handler we created */ - handler.close(); - } -} \ No newline at end of file diff --git a/doc/examples/java-jul/FilterChangeListenerExample.java b/doc/examples/java-jul/FilterChangeListenerExample.java new file mode 100644 index 00000000..c1f158ae --- /dev/null +++ b/doc/examples/java-jul/FilterChangeListenerExample.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2015 - EfficiOS Inc., Alexandre Montplaisir + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +import java.io.IOException; +import java.util.logging.Level; + +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.filter.FilterChangeNotifier; +import org.lttng.ust.agent.filter.IFilterChangeListener; +import org.lttng.ust.agent.jul.LttngLogHandler; +import org.lttng.ust.agent.session.EventRule; +import org.lttng.ust.agent.session.LogLevelSelector; + +/** + * Example usage of a {@link IFilterChangeListener}. + * + * This listener will simply print to stdout the notifications it receives. To + * try it, run the program, then issue "lttng enable-event" and + * "lttng disable-event" commands for the JUL domain. + * + * @author Alexandre Montplaisir + */ +public class FilterChangeListenerExample { + + private static class ExampleFilterChangeListener implements IFilterChangeListener { + + @Override + public void eventRuleAdded(EventRule rule) { + System.out.println(); + System.out.println("New event rule enabled:"); + System.out.println("Event name: " + rule.getEventName()); + System.out.println(printLogLevel(rule.getLogLevelSelector())); + System.out.println("Filter string: " + rule.getFilterString()); + } + + @Override + public void eventRuleRemoved(EventRule rule) { + System.out.println(); + System.out.println("Event rule disabled:"); + System.out.println("Event name: " + rule.getEventName()); + System.out.println(printLogLevel(rule.getLogLevelSelector())); + System.out.println("Filter string: " + rule.getFilterString()); + } + + /** + * Convenience method to print integer log level values into their JUL + * equivalent. + */ + private static String printLogLevel(LogLevelSelector lls) { + String llname = Level.parse(String.valueOf(lls.getLogLevel())).getName(); + return "Log level: " + llname + ", filter type: " + lls.getLogLevelType().toString(); + } + } + + /** + * Run the program. + * + * @param args + * Command-line arguments (not used) + * @throws IOException + */ + public static void main(String args[]) throws IOException { + /* We need at least one log handler to activate the LTTng agent */ + ILttngHandler handler = new LttngLogHandler(); + + /* Create a listener and register it to the manager */ + IFilterChangeListener listener = new ExampleFilterChangeListener(); + FilterChangeNotifier.getInstance().registerListener(listener); + + System.out.println("Press Enter to finish."); + System.in.read(); + + /* Unregister the listener */ + FilterChangeNotifier.getInstance().unregisterListener(listener); + + /* Cleanup the log handler we created */ + handler.close(); + } +} diff --git a/doc/examples/java-jul/Makefile b/doc/examples/java-jul/Makefile index 8cbc23b3..f4dacdd6 100644 --- a/doc/examples/java-jul/Makefile +++ b/doc/examples/java-jul/Makefile @@ -40,7 +40,7 @@ JC = javac -classpath "$(CLASSPATH):." .java.class: $(JC) $(JFLAGS) $*.java -CLASSES = Hello.java FilerChangeListenerExample.java +CLASSES = Hello.java FilterChangeListenerExample.java all: classes