Skip to content

Commit

Permalink
SLF4J loggers config
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-rider committed Jan 18, 2020
1 parent e0ddef2 commit 65555b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ public class Log
private static ThreadLocal<PrintWriter> logWriter = new ThreadLocal<>();
private static boolean quietMode;
private static PrintWriter DEFAULT_DEBUG_WRITER;
private final boolean doEclipseLog;

public static Log getLog(Class<?> forClass) {
return new Log(forClass.getName());
return new Log(forClass.getName(), false);
}

public static Log getLog(String name) {
return new Log(name);
return new Log(name, true);
}

public static Log getLog(String name, boolean doEclipseLog) {
return new Log(name, doEclipseLog);
}

public static boolean isQuietMode() {
Expand Down Expand Up @@ -109,8 +114,9 @@ public void log(IStatus status) {
}
}

private Log(String name) {
private Log(String name, boolean doEclipseLog) {
this.name = name;
this.doEclipseLog = doEclipseLog;
}

public void flush() {
Expand Down Expand Up @@ -280,7 +286,7 @@ private void writeExceptionStatus(int severity, Object message, Throwable t)
}

private void writeEclipseLog(IStatus status) {
if (logWriter.get() == null && eclipseLog != null) {
if (doEclipseLog && logWriter.get() == null && eclipseLog != null) {
eclipseLog.log(status);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class SLFLogger implements Logger {
private final Log log;

public SLFLogger(String name) {
log = Log.getLog(name);
// Do not write to Eclipse log from 3rd party loggers
log = Log.getLog(name, false);
}

@Override
Expand Down

0 comments on commit 65555b0

Please sign in to comment.