Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 14ff41f4524d
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 237760b2d1ba
Choose a head ref
  • 4 commits
  • 1 file changed
  • 1 contributor

Commits on Dec 18, 2016

  1. Copy the full SHA
    784cb74 View commit details
  2. Copy the full SHA
    2e7c694 View commit details
  3. Copy the full SHA
    ec05e33 View commit details
  4. [Truffle] Make the Ruby logging handler a named class so we can refer…

    … to it from configuration.
    chrisseaton committed Dec 18, 2016
    Copy the full SHA
    237760b View commit details
Showing with 21 additions and 34 deletions.
  1. +21 −34 truffle/src/main/java/org/jruby/truffle/Log.java
55 changes: 21 additions & 34 deletions truffle/src/main/java/org/jruby/truffle/Log.java
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

@@ -34,27 +35,30 @@ public RubyLevel(String name, Level parent) {

private static final Logger LOGGER = createLogger();

private static Logger createLogger() {
final Logger logger = Logger.getLogger("org.jruby.truffle");
public static class RubyHandler extends Handler {

logger.setUseParentHandlers(false);
@Override
public void publish(LogRecord record) {
System.err.printf("[ruby] %s %s%n", record.getLevel().getName(), record.getMessage());
}

logger.addHandler(new Handler() {
@Override
public void flush() {
}

@Override
public void publish(LogRecord record) {
System.err.printf("[ruby] %s %s%n", record.getLevel().getName(), record.getMessage());
}
@Override
public void close() throws SecurityException {
}

@Override
public void flush() {
}
}

@Override
public void close() throws SecurityException {
}
private static Logger createLogger() {
final Logger logger = Logger.getLogger("org.jruby.truffle");

});
if (LogManager.getLogManager().getProperty("org.jruby.truffle.handlers") == null) {
logger.setUseParentHandlers(false);
logger.addHandler(new RubyHandler());
}

return logger;
}
@@ -75,32 +79,15 @@ public static void notOptimizedOnce(String message) {
}
}

/**
* Warn about code that works but is not yet optimized as Truffle code normally would be. Only prints the warning
* if called from compiled code. Don't call this method from behind a boundary or transfer, as it will never print
* the warning because it will never be called from compiled code. Use {@link #performance} instead if you need to
* warn in code that is never compiled.
*/
public static void notOptimized(String message) {
if (CompilerDirectives.inCompiledCode()) {
performance(message);
}
}

/**
* Warn about something that has lower performance than might be expected. Only prints the warning once.
*/
@TruffleBoundary
public static void performanceOnce(String message) {
// This isn't double-checked locking, because we aren't publishing an object that is then used

if (!displayedWarnings.contains(message)) {
synchronized (displayedWarnings) {
if (!displayedWarnings.contains(message)) {
displayedWarnings.add(message);
performance(message);
}
}
if (displayedWarnings.add(message)) {
performance(message);
}
}