30 import java.security.PrivilegedAction;
31 import java.util.HashMap;
32 import java.util.Iterator;
33 import java.util.Map;
34 import java.util.ResourceBundle;
35 import java.util.ServiceLoader;
36 import java.util.function.BooleanSupplier;
37 import java.util.function.Function;
38 import java.util.function.Supplier;
39 import java.lang.System.LoggerFinder;
40 import java.lang.System.Logger;
41 import java.lang.System.Logger.Level;
42 import java.lang.ref.WeakReference;
43 import java.util.Objects;
44 import java.util.concurrent.ExecutionException;
45 import java.util.concurrent.ExecutorService;
46 import java.util.concurrent.LinkedBlockingQueue;
47 import java.util.concurrent.ThreadFactory;
48 import java.util.concurrent.ThreadPoolExecutor;
49 import java.util.concurrent.TimeUnit;
50 import sun.misc.InnocuousThread;
51 import jdk.internal.misc.VM;
52 import sun.util.logging.PlatformLogger;
53 import jdk.internal.logger.LazyLoggers.LazyLoggerAccessor;
54
55 /**
56 * The BootstrapLogger class handles all the logic needed by Lazy Loggers
57 * to delay the creation of System.Logger instances until the VM is booted.
58 * By extension - it also contains the logic that will delay the creation
59 * of JUL Loggers until the LogManager is initialized by the application, in
60 * the common case where JUL is the default and there is no custom JUL
61 * configuration.
62 *
63 * A BootstrapLogger instance is both a Logger and a
64 * PlatformLogger.Bridge instance, which will put all Log messages in a queue
65 * until the VM is booted.
66 * Once the VM is booted, it obtain the real System.Logger instance from the
67 * LoggerFinder and flushes the message to the queue.
68 *
69 * There are a few caveat:
70 * - the queue may not be flush until the next message is logged after
|
30 import java.security.PrivilegedAction;
31 import java.util.HashMap;
32 import java.util.Iterator;
33 import java.util.Map;
34 import java.util.ResourceBundle;
35 import java.util.ServiceLoader;
36 import java.util.function.BooleanSupplier;
37 import java.util.function.Function;
38 import java.util.function.Supplier;
39 import java.lang.System.LoggerFinder;
40 import java.lang.System.Logger;
41 import java.lang.System.Logger.Level;
42 import java.lang.ref.WeakReference;
43 import java.util.Objects;
44 import java.util.concurrent.ExecutionException;
45 import java.util.concurrent.ExecutorService;
46 import java.util.concurrent.LinkedBlockingQueue;
47 import java.util.concurrent.ThreadFactory;
48 import java.util.concurrent.ThreadPoolExecutor;
49 import java.util.concurrent.TimeUnit;
50 import jdk.internal.misc.InnocuousThread;
51 import jdk.internal.misc.VM;
52 import sun.util.logging.PlatformLogger;
53 import jdk.internal.logger.LazyLoggers.LazyLoggerAccessor;
54
55 /**
56 * The BootstrapLogger class handles all the logic needed by Lazy Loggers
57 * to delay the creation of System.Logger instances until the VM is booted.
58 * By extension - it also contains the logic that will delay the creation
59 * of JUL Loggers until the LogManager is initialized by the application, in
60 * the common case where JUL is the default and there is no custom JUL
61 * configuration.
62 *
63 * A BootstrapLogger instance is both a Logger and a
64 * PlatformLogger.Bridge instance, which will put all Log messages in a queue
65 * until the VM is booted.
66 * Once the VM is booted, it obtain the real System.Logger instance from the
67 * LoggerFinder and flushes the message to the queue.
68 *
69 * There are a few caveat:
70 * - the queue may not be flush until the next message is logged after
|