Handle core's log refactoring

Original commit: elastic/x-pack-elasticsearch@9e2e41db90
This commit is contained in:
Nik Everett 2016-02-19 05:52:35 -08:00
parent 06fc60c2f6
commit d7170197f6
16 changed files with 42 additions and 63 deletions

View File

@ -24,7 +24,7 @@ import org.elasticsearch.common.inject.Singleton;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
import org.elasticsearch.common.joda.Joda;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;

View File

@ -7,7 +7,7 @@ package org.elasticsearch.marvel.license;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.core.License;
import org.elasticsearch.license.plugin.core.AbstractLicenseeComponent;

View File

@ -8,13 +8,12 @@ package org.elasticsearch.shield.action.interceptor;
import org.elasticsearch.action.CompositeIndicesRequest;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.shield.User;
import org.elasticsearch.shield.authz.InternalAuthorizationService;
import org.elasticsearch.shield.authz.accesscontrol.IndicesAccessControl;
import org.elasticsearch.transport.TransportRequest;
import java.util.Collections;
import java.util.List;

View File

@ -16,7 +16,7 @@ import org.apache.lucene.util.BitSet;
import org.apache.lucene.util.BitSetIterator;
import org.apache.lucene.util.Bits;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
import java.io.IOException;

View File

@ -26,7 +26,7 @@ import org.apache.lucene.util.FilterIterator;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentType;

View File

@ -24,8 +24,8 @@ import org.apache.lucene.util.SparseFixedBitSet;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;

View File

@ -8,13 +8,14 @@ package org.elasticsearch.shield.support;
import org.elasticsearch.common.logging.ESLogger;
/**
*
* A logger that doesn't log anything.
*/
public class NoOpLogger implements ESLogger {
public class NoOpLogger extends ESLogger {
public static final ESLogger INSTANCE = new NoOpLogger();
private NoOpLogger() {
super(null, null);
}
@Override

View File

@ -5,16 +5,18 @@
*/
package org.elasticsearch.shield.audit.logfile;
import org.elasticsearch.common.logging.support.AbstractESLogger;
import org.elasticsearch.common.logging.ESLogger;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import static org.elasticsearch.common.logging.LoggerMessageFormat.format;
/**
*
*/
public class CapturingLogger extends AbstractESLogger {
public class CapturingLogger extends ESLogger {
private Level level;
@ -25,58 +27,43 @@ public class CapturingLogger extends AbstractESLogger {
public final List<Msg> trace = new ArrayList<>();
public CapturingLogger(Level level) {
super("");
super(null, null);
this.level = level;
}
@Override
protected void internalTrace(String msg) {
add(trace, msg);
public void trace(String msg, Throwable cause, Object... params) {
if (isTraceEnabled()) {
add(trace, format(msg, params), cause);
}
}
@Override
protected void internalTrace(String msg, Throwable cause) {
add(trace, msg, cause);
public void debug(String msg, Throwable cause, Object... params) {
if (isDebugEnabled()) {
add(debug, format(msg, params), cause);
}
}
@Override
protected void internalDebug(String msg) {
add(debug, msg);
public void info(String msg, Throwable cause, Object... params) {
if (isInfoEnabled()) {
add(info, format(msg, params), cause);
}
}
@Override
protected void internalDebug(String msg, Throwable cause) {
add(debug, msg, cause);
public void warn(String msg, Throwable cause, Object... params) {
if (isWarnEnabled()) {
add(warn, format(msg, params), cause);
}
}
@Override
protected void internalInfo(String msg) {
add(info, msg);
}
@Override
protected void internalInfo(String msg, Throwable cause) {
add(info, msg, cause);
}
@Override
protected void internalWarn(String msg) {
add(warn, msg);
}
@Override
protected void internalWarn(String msg, Throwable cause) {
add(warn, msg, cause);
}
@Override
protected void internalError(String msg) {
add(error, msg);
}
@Override
protected void internalError(String msg, Throwable cause) {
add(error, msg, cause);
public void error(String msg, Throwable cause, Object... params) {
if (isErrorEnabled()) {
add(error, format(msg, params), cause);
}
}
@Override
@ -135,10 +122,6 @@ public class CapturingLogger extends AbstractESLogger {
}
}
private static void add(List<Msg> list, String text) {
list.add(new Msg(text));
}
private static void add(List<Msg> list, String text, Throwable t) {
list.add(new Msg(text, t));
}
@ -151,10 +134,6 @@ public class CapturingLogger extends AbstractESLogger {
public String text;
public Throwable t;
public Msg(String text) {
this.text = text;
}
public Msg(String text, Throwable t) {
this.text = text;
this.t = t;

View File

@ -13,8 +13,8 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Setting;

View File

@ -6,7 +6,7 @@
package org.elasticsearch.watcher.actions;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;

View File

@ -6,7 +6,7 @@
package org.elasticsearch.watcher.actions.throttler;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.watcher.execution.WatchExecutionContext;
/**

View File

@ -38,7 +38,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.elasticsearch.common.logging.support.LoggerMessageFormat.format;
import static org.elasticsearch.common.logging.LoggerMessageFormat.format;
/**
*/

View File

@ -10,7 +10,7 @@ import org.elasticsearch.script.ScriptException;
import java.io.IOException;
import static org.elasticsearch.common.logging.support.LoggerMessageFormat.format;
import static org.elasticsearch.common.logging.LoggerMessageFormat.format;
/**
*

View File

@ -5,7 +5,7 @@
*/
package org.elasticsearch.watcher.support.validation;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import java.util.regex.Pattern;

View File

@ -8,7 +8,7 @@ package org.elasticsearch.watcher.support.validation;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.watcher.support.Exceptions;

View File

@ -17,7 +17,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.elasticsearch.common.logging.support.LoggerMessageFormat.format;
import static org.elasticsearch.common.logging.LoggerMessageFormat.format;
/**
*