From 22e2ffbf873fbfc963ac866824713b3147929e78 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 2 Jul 2018 12:10:15 +0200 Subject: [PATCH] More flexible logger factory access and initialization This allows to create a logger that wraps the standard IDEA logger (for rdserver) --- .../com/intellij/openapi/diagnostic/Logger.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/diagnostic/Logger.java b/platform/util/src/com/intellij/openapi/diagnostic/Logger.java index 0c94da531ca4..540173181772 100644 --- a/platform/util/src/com/intellij/openapi/diagnostic/Logger.java +++ b/platform/util/src/com/intellij/openapi/diagnostic/Logger.java @@ -1,6 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.diagnostic; import com.intellij.util.ArrayUtil; @@ -52,6 +50,19 @@ public abstract class Logger { } } + public static void setFactory(Factory factory) { + if (isInitialized()) { + //noinspection UseOfSystemOutOrSystemErr + System.out.println("Changing log factory\n" + ExceptionUtil.getThrowableText(new Throwable())); + } + + ourFactory = factory; + } + + public static Factory getFactory() { + return ourFactory; + } + public static boolean isInitialized() { return !(ourFactory instanceof DefaultFactory); }