< prev index next >

jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 31,40 **** --- 31,41 ---- import java.io.*; import java.time.Clock; import jdk.internal.misc.JavaLangAccess; import jdk.internal.misc.SharedSecrets; + import static sun.util.logger.SimpleConsoleLogger.skipLoggingFrame; /** * LogRecord objects are used to pass logging requests between * the logging framework and individual log Handlers. * <p>
*** 635,644 **** --- 636,666 ---- needToInferCaller = false; } // Private method to infer the caller's class and method names + // + // Note: + // For testing purposes - it is possible to customize the process + // by which LogRecord will infer the source class name and source method name + // when analyzing the call stack. + // <p> + // The system property {@code jdk.logger.packages} can define a comma separated + // list of strings corresponding to additional package name prefixes that + // should be ignored when trying to infer the source caller class name. + // Those stack frames whose {@linkplain StackTraceElement#getClassName() + // declaring class name} start with one such prefix will be ignored. + // <p> + // This is primarily useful when providing utility logging classes wrapping + // a logger instance, as it makes it possible to instruct LogRecord to skip + // those utility frames when inferring the caller source class name. + // <p> + // The {@code jdk.logger.packages} system property is consulted only once. + // <p> + // This property is not standard, implementation specific, and yet + // undocumented (and thus subject to changes without notice). + // private void inferCaller() { needToInferCaller = false; JavaLangAccess access = SharedSecrets.getJavaLangAccess(); Throwable throwable = new Throwable(); int depth = access.getStackTraceDepth(throwable);
*** 656,667 **** if (isLoggerImpl) { lookingForLogger = false; } } else { if (!isLoggerImpl) { ! // skip reflection call ! if (!cname.startsWith("java.lang.reflect.") && !cname.startsWith("sun.reflect.")) { // We've found the relevant frame. setSourceClassName(cname); setSourceMethodName(frame.getMethodName()); return; } --- 678,689 ---- if (isLoggerImpl) { lookingForLogger = false; } } else { if (!isLoggerImpl) { ! // skip logging/logger infrastructure and reflection calls ! if (!skipLoggingFrame(cname)) { // We've found the relevant frame. setSourceClassName(cname); setSourceMethodName(frame.getMethodName()); return; }
*** 673,681 **** } private boolean isLoggerImplFrame(String cname) { // the log record could be created for a platform logger return (cname.equals("java.util.logging.Logger") || ! cname.startsWith("java.util.logging.LoggingProxyImpl") || ! cname.startsWith("sun.util.logging.")); } } --- 695,702 ---- } private boolean isLoggerImplFrame(String cname) { // the log record could be created for a platform logger return (cname.equals("java.util.logging.Logger") || ! cname.startsWith("sun.util.logging.PlatformLogger")); } }
< prev index next >