org.mentalog.DefaultLogger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of menta-log Show documentation
Show all versions of menta-log Show documentation
A log library that embraces the kiss principle.
package org.mentalog;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
import org.mentalog.encoder.Encoder;
import org.mentalog.interceptor.Interceptor;
import org.mentalog.timestamper.Timestamper;
import org.mentalog.util.Benchmarker;
import org.mentalog.util.LogEventUtils;
import org.mentalog.util.StringBuilderUtils;
class DefaultLogger implements Logger {
private static final byte[] HEADER_START = "LOG OPENED - ".getBytes();
private static final byte[] COLOR_CLOSING = "\033[0m".getBytes();
private PrintStream printStream;
private boolean enabled = true;
private byte[] prefix = null;
private final StringBuilder sb = new StringBuilder(128);
private final String filename;
private final boolean isSystemOutOrErr;
private final boolean isSynchronized;
private final byte[] color;
private final Timestamper timestamper;
private final List encoders;
private final List interceptors = new ArrayList(8);
private final Log level;
private final boolean isMemoryMapped;
private final boolean isAsynchronous;
// protected:
protected ByteBuffer buffer;
protected FileChannel fileChannel;
protected RandomAccessFile raf = null;
protected File outputFile = null;
/**
* Starts a logger that will append to the given filename, using the given prefix before each log message.
*
* @param filename
* The log file
* @param prefix
* A string that will appear before each log message.
* @throws IOException
*/
DefaultLogger(final String filename, Timestamper timestamper, final boolean isSynchronized, boolean isMemoryMapped, int memoryMappedBufferSize, List encoders, Log level, boolean isAsynchronous) throws IOException {
this.color = null;
this.level = level;
this.encoders = encoders;
this.timestamper = timestamper;
this.isSynchronized = isSynchronized;
this.isSystemOutOrErr = false;
this.filename = filename;
this.printStream = null;
this.outputFile = new File(filename);
this.isMemoryMapped = isMemoryMapped;
if (isMemoryMapped) {
this.buffer = createMappedByteBuffer(outputFile, memoryMappedBufferSize);
} else {
this.fileChannel = (new FileOutputStream(outputFile, true)).getChannel();
this.buffer = ByteBuffer.allocateDirect(Log.getBufferSize());
}
this.prefix = null;
this.isAsynchronous = isAsynchronous;
printTopHeader(outputFile.length() == 0);
addShutdownHook();
}
DefaultLogger(final String dir, final String filename, Timestamper timestamper, final boolean isSynchronized, boolean isMemoryMapped, int memoryMappedBufferSize, List encoders, Log level, boolean isAsynchronous) throws IOException {
this.color = null;
this.level = level;
this.encoders = encoders;
this.timestamper = timestamper;
this.isSynchronized = isSynchronized;
this.isSystemOutOrErr = false;
if (dir == null || dir.trim().equals("")) {
sb.append("");
} else if (!dir.endsWith(File.separator) && !filename.startsWith(File.separator)) {
sb.append(dir).append(File.separator);
}
sb.append(filename);
this.filename = sb.toString();
this.printStream = null;
this.outputFile = new File(this.filename);
this.isMemoryMapped = isMemoryMapped;
if (isMemoryMapped) {
this.buffer = createMappedByteBuffer(outputFile, memoryMappedBufferSize);
} else {
this.fileChannel = (new FileOutputStream(outputFile, true)).getChannel();
this.buffer = ByteBuffer.allocateDirect(Log.getBufferSize());
}
this.prefix = null;
this.isAsynchronous = isAsynchronous;
printTopHeader(outputFile.length() == 0);
addShutdownHook();
}
DefaultLogger(final PrintStream stream, final String prefix, Timestamper timestamper, final boolean isSynchronized, byte[] color, List encoders, Log level, boolean isAsynchronous) {
this.color = color;
this.level = level;
this.encoders = encoders;
this.timestamper = timestamper;
this.isSynchronized = isSynchronized;
this.isSystemOutOrErr = (stream == System.out || stream == System.err);
this.filename = null;
this.fileChannel = null;
this.buffer = ByteBuffer.allocateDirect(Log.getBufferSize());
this.isMemoryMapped = false;
this.printStream = stream;
this.isAsynchronous = isAsynchronous;
this.prefix = prefix != null ? prefix.getBytes() : null;
if (!isSystemOutOrErr) {
addShutdownHook();
}
}
private void addShutdownHook() {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
close();
}
});
}
protected MappedByteBuffer createMappedByteBuffer(File file, int size) {
throwException();
return null;
}
@Override
public String toString() {
String type = this.getClass().getSimpleName();
StringBuilder sb = new StringBuilder(128);
sb.append(type).append("=[");
if (filename != null) {
sb.append("file=").append(filename);
} else if (printStream == System.out) {
sb.append("stream=System.out");
} else if (printStream == System.err) {
sb.append("stream=System.err");
} else {
sb.append("stream=").append(printStream);
}
sb.append(", isSynchronized=").append(isSynchronized);
sb.append(", isMemoryMappedFile=").append(isMemoryMapped);
sb.append(", isAsynchronous=").append(isAsynchronous);
sb.append(", isExtended=").append(Log.isExtended());
sb.append("]");
return sb.toString();
}
@Override
public void addInterceptor(Interceptor interceptor) {
if (isSynchronized) {
synchronized(this) {
interceptors.add(interceptor);
}
} else {
interceptors.add(interceptor);
}
}
@Override
public void removeInterceptor(Interceptor interceptor) {
if (isSynchronized) {
synchronized (this) {
interceptors.remove(interceptor);
}
} else {
interceptors.remove(interceptor);
}
}
@Override
public void close() {
if (isSynchronized) {
synchronized(this) {
closeImpl();
}
} else {
closeImpl();
}
}
private void closeImpl() {
if (isSystemOutOrErr) {
return;
}
try {
if (isMemoryMapped) {
closeAllMemoryMappedBuffers(Log.isForceOnClose());
} else {
if (fileChannel != null) {
flushByteBuffer();
fileChannel.close();
}
if (printStream != null) {
printStream.close();
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
public void enable(boolean b) {
if (isSynchronized) {
synchronized(this) {
this.enabled = b;
}
} else {
this.enabled = b;
}
}
@Override
public void roll() {
if (isSynchronized) {
synchronized(this) {
rollImpl();
}
} else {
rollImpl();
}
}
private final void throwException() {
throw new IllegalStateException("Memory-mapped files are not supported. Check http://mentalog.soliveirajr.com for details on how to activate it.");
}
protected void closeAllMemoryMappedBuffers(boolean forceBuffers) {
throwException();
}
private void rollImpl() {
if (outputFile == null || !outputFile.exists()) {
return;
}
closeImpl();
sb.setLength(0);
sb.append(outputFile.getAbsolutePath());
printRollDateTime(sb);
final String rollFilename = sb.toString();
outputFile.renameTo(new File(rollFilename));
outputFile = new File(this.filename);
try {
fileChannel = (new FileOutputStream(outputFile, false)).getChannel();
printTopHeader(outputFile.length() == 0);
} catch(Exception e) {
throw new LogException("Error rolling log file!", e);
}
}
private void printTopHeaderDateTime(StringBuilder sb) {
long now = System.currentTimeMillis();
// dd/MM/yyyy HH:mm:ss
char[] dd = Log.DATETIME_FORMATTER.getDay(now);
char[] MM = Log.DATETIME_FORMATTER.getMonth(now);
char[] yyyy = Log.DATETIME_FORMATTER.getYear(now);
printTo(sb, dd);
sb.append('/');
printTo(sb, MM);
sb.append('/');
printTo(sb, yyyy);
sb.append(' ');
Log.DATETIME_FORMATTER.formatTimeTo(sb, now);
}
private void printRollDateTime(StringBuilder sb) {
long now = System.currentTimeMillis();
// -yyyyMMdd-HHmmss
char[] dd = Log.DATETIME_FORMATTER.getDay(now);
char[] MM = Log.DATETIME_FORMATTER.getMonth(now);
char[] yyyy = Log.DATETIME_FORMATTER.getYear(now);
sb.append('-');
printTo(sb, yyyy);
printTo(sb, MM);
printTo(sb, dd);
sb.append('-');
char[] time = Log.DATETIME_FORMATTER.formatTime(now);
// HH:mm:ss.SSS
// 0123456789 10 11
printTo(sb, time, 0, 2);
printTo(sb, time, 3, 2);
printTo(sb, time, 6, 2);
}
private final void printTo(StringBuilder sb, char[] c) {
for(int i = 0; i < c.length; i++) {
sb.append(c[i]);
}
}
private final void printTo(StringBuilder sb, char[] c, int pos, int length) {
for(int i = pos; i < pos + length; i++) {
sb.append(c[i]);
}
}
protected void printTopHeader(boolean newFile) {
sb.setLength(0);
printTopHeaderDateTime(sb);
if (!newFile) {
buffer.put((byte) '\n');
}
buffer.put(HEADER_START);
transferStringBuilderToByteBuffer(sb, buffer);
buffer.put((byte) '\n');
flushByteBuffer();
}
protected void flushForMemoryMappedBuffer() {
throwException();
}
private void flushByteBuffer() {
if (buffer.position() > 0) {
if (isMemoryMapped) {
flushForMemoryMappedBuffer();
} else {
buffer.flip();
if (fileChannel != null) {
try {
fileChannel.write(buffer);
} catch (Exception e) {
throw new LogException("Error writting to log file!", e);
}
if (buffer.hasRemaining()) {
throw new LogException("Failed to write buffer to file!");
}
} else if (printStream != null) {
int rem = buffer.remaining();
for (int i = 0; i < rem; i++) {
printStream.write(buffer.get());
}
printStream.flush();
}
buffer.clear();
}
}
}
protected void header(final long timestamp) {
long timeInMillis;
if (timestamper.getPrecision() == Timestamper.Precision.MICROS) {
// timestamp came in micros...
timeInMillis = timestamp / 1000L; // micros => millis
} else if (timestamper.getPrecision() == Timestamper.Precision.NANOS) {
timeInMillis = timestamp / 1000000L; // nanos => millis
} else {
timeInMillis = timestamp;
}
sb.setLength(0);
Log.DATETIME_FORMATTER.formatTimeTo(sb, timeInMillis);
if (timestamper.getPrecision() == Timestamper.Precision.MICROS) {
long extraMicros = timestamp - (timeInMillis * 1000L);
if (extraMicros == 0) {
sb.append("000");
} else if (extraMicros < 10) {
sb.append("00").append(extraMicros);
} else if (extraMicros < 100) {
sb.append("0").append(extraMicros);
} else if (extraMicros < 1000) {
sb.append(extraMicros);
} else if (extraMicros == 1000) {
sb.append("999");
} else {
throw new LogException("Got a bad micro time: " + extraMicros);
}
} else if (timestamper.getPrecision() == Timestamper.Precision.NANOS) {
long extraNanos = timestamp - (timeInMillis * 1000L * 1000L);
if (extraNanos == 0) {
sb.append("000000");
} else if (extraNanos < 10) {
sb.append("00000").append(extraNanos);
} else if (extraNanos < 100) {
sb.append("0000").append(extraNanos);
} else if (extraNanos < 1000) {
sb.append("000");
} else if (extraNanos < 10000) {
sb.append("00");
} else if (extraNanos < 100000) {
sb.append("0");
} else if (extraNanos < 1000000) {
sb.append(extraNanos);
} else if (extraNanos == 1000000) {
sb.append("999999");
} else {
throw new LogException("Got a bad nano time: " + extraNanos);
}
}
transferStringBuilderToByteBuffer(sb, buffer);
if (prefix != null) {
buffer.put((byte) '-');
buffer.put(prefix);
}
}
private final static void transferStringBuilderToByteBuffer(final StringBuilder sb, final ByteBuffer bb) {
final int len = sb.length();
for (int i = 0; i < len; i++) {
bb.put((byte) sb.charAt(i));
}
}
private final static void transferCharSequenceToByteBuffer(CharSequence s, ByteBuffer bb) {
int len = s.length();
for (int i = 0; i < len; i++) {
bb.put((byte) s.charAt(i));
}
}
@Override
public void log(Object ... objects) {
log(isAsynchronous, objects);
}
@Override
public void log(boolean async, final Object ... objects) {
if (Log.isBenchmark()) {
Benchmarker.instance().mark();
}
if (isSynchronized) {
synchronized(this) {
if (async) {
AsyncThread.logLater(this, Log.isProducerLazySet(), objects);
} else {
logImpl(objects);
}
}
} else {
if (async) {
AsyncThread.logLater(this, Log.isProducerLazySet(), objects);
} else {
logImpl(objects);
}
}
}
private final static StackTraceElement findCorrectElement(StackTraceElement[] stack) {
for (int i = 1 /* skip first one */; i < stack.length; i++) {
StackTraceElement elem = stack[i];
String klass = elem.getClassName();
// for level...
if (!klass.equals(Log.class.getName()) && !klass.equals(DefaultLogger.class.getName())) {
return elem;
}
}
return null;
}
private final void logImpl(final Object... objects) {
StringBuilderUtils.reset(); // useful if we are using StringBuilderUtils to avoid autoboxing...
// just keep in mind that this is SO not thread safe...
if (objects == null || objects.length == 0) {
throw new IllegalStateException("Cannot log null or zero length array!");
}
if (!enabled) {
return;
}
boolean shouldFilter = false;
if (Log.getFilter() != null) {
shouldFilter = true;
String[] filter = Log.getFilter();
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
StackTraceElement elem = findCorrectElement(stack);
if (elem == null) {
return;
}
String klass = elem.getClassName();
for(String f : filter) {
if (f.equals("*")) {
shouldFilter = false;
break;
} else if (f.endsWith("*")) {
f = f.substring(0, f.length() - 1);
if (klass.startsWith(f)) {
shouldFilter = false;
break;
}
} else {
if (klass.equals(f)) {
shouldFilter = false;
break;
}
}
}
}
if (shouldFilter) {
return;
}
if (color != null) {
buffer.put(color);
}
header(timestamper.getTimestamp());
// grab class and line if necessary...
if (Log.isShowClassAndLineNumber()) {
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
StackTraceElement elem = findCorrectElement(stack);
if (elem != null) {
buffer.put((byte) '-');
transferCharSequenceToByteBuffer(elem.getClassName(), buffer);
buffer.put((byte) ':');
transferCharSequenceToByteBuffer(String.valueOf(elem.getLineNumber()), buffer); // you should not use this in production
}
}
buffer.put((byte) ' ');
int count = 0;
boolean lastObjectEndsWithEqualSign = false;
int currPlaceholderIndex = -1;
CharSequence placeholderCharSequence = null;
for (int varargsPos = 0; varargsPos < objects.length; varargsPos++) {
Object object = objects[varargsPos];
if (varargsPos == 0 && objects.length > 0 && object instanceof CharSequence) {
CharSequence cs = (CharSequence) object;
currPlaceholderIndex = indexOfPlaceholder(cs, 0);
if (currPlaceholderIndex >= 0) {
placeholderCharSequence = cs;
copySubstring(placeholderCharSequence, buffer, 0, currPlaceholderIndex, true);
continue;
}
}
if (count++ > 0 && placeholderCharSequence == null) {
if ((!Log.isNoSpaceAfterEqualSign() || !lastObjectEndsWithEqualSign) && !Log.isNoSpaceBetweenObjects()) {
buffer.put((byte) ' ');
}
}
lastObjectEndsWithEqualSign = false;
boolean foundEncoder = false;
if (encoders != null) {
int len = encoders.size();
for(int i = len - 1; i >= 0; i--) { // backwards so the last added is the first processed!
if (encoders.get(i).encode(object, buffer, varargsPos, objects.length)) {
foundEncoder = true;
break;
}
}
}
if (!foundEncoder) {
transferCharSequenceToByteBuffer(object.toString(), buffer);
}
if (placeholderCharSequence != null) {
// need to find the next placeholder and copy the next part of the string...
int nextPlaceholderIndex = indexOfPlaceholder(placeholderCharSequence, currPlaceholderIndex + 2);
if (nextPlaceholderIndex == -1) {
// end
if (currPlaceholderIndex + 2 < placeholderCharSequence.length()) {
copySubstring(placeholderCharSequence, buffer, currPlaceholderIndex + 2, placeholderCharSequence.length(), false);
}
break;
} else {
// do we have more object?
if (varargsPos == objects.length - 1) { // last...
// copy the whole remaining thing
copySubstring(placeholderCharSequence, buffer, currPlaceholderIndex + 2, placeholderCharSequence.length(), false);
} else {
// copy the next section...
copySubstring(placeholderCharSequence, buffer, currPlaceholderIndex + 2, nextPlaceholderIndex, true);
currPlaceholderIndex = nextPlaceholderIndex;
}
}
}
if (Log.isNoSpaceAfterEqualSign() && object instanceof CharSequence && placeholderCharSequence == null) {
// logic for equal sign
CharSequence cs = (CharSequence) object;
lastObjectEndsWithEqualSign = cs.length() > 0 && cs.charAt(cs.length() - 1) == '=';
}
}
if (color != null) {
buffer.put(COLOR_CLOSING);
}
boolean aborted = false;
if (interceptors != null) {
int len = interceptors.size();
int pos = buffer.position();
int lim = buffer.limit();
for(int i = 0; i < len; i++) {
buffer.flip();
boolean shouldContinue = interceptors.get(i).onLogBuffer(buffer, level);
if (!shouldContinue) {
aborted = true;
}
buffer.limit(lim).position(pos); // reset
}
}
if (!aborted) {
buffer.put((byte) '\n');
flushByteBuffer();
if (Log.isBenchmark()) {
Benchmarker.instance().measure();
}
} else {
buffer.clear();
}
}
private final static int indexOfPlaceholder(CharSequence cs, int start) {
int len = cs.length();
for (int i = start; i < len; i++) {
if (cs.charAt(i) == '{' && i + 1 < len && cs.charAt(i + 1) == '}') {
boolean hasOneScape = i - 1 >= 0 && cs.charAt(i - 1) == '\\';
boolean hasTwoScapes = i - 2 >= 0 && cs.charAt(i - 2) == '\\';
if (hasOneScape && !hasTwoScapes) {
continue;
}
return i;
}
}
return -1;
}
private final static void copySubstring(CharSequence cs, ByteBuffer bb, int start, int end, boolean fixEscape) {
for (int i = start; i < end; i++) {
char currChar = cs.charAt(i);
if (fixEscape) {
if (currChar == '\\') {
if (i + 1 < end && cs.charAt(i + 1) == '\\') {
if (i + 1 == end - 1) {
continue;
}
}
}
}
if (currChar == '\\') {
if (i + 1 < end && cs.charAt(i + 1) == '{') {
if (i + 2 < end && cs.charAt(i + 2) == '}') {
continue; // skip '\' before {}
}
}
}
bb.put((byte) currChar);
}
}
@Override
public boolean isEnabled() {
if (isSynchronized) {
synchronized(this) {
return enabled;
}
} else {
return enabled;
}
}
/////// VARARGS /////
@Override
public final Object[] getVarargs(int size) {
switch(size) {
case 1:
return oa1;
case 2:
return oa2;
case 3:
return oa3;
case 4:
return oa4;
case 5:
return oa5;
case 6:
return oa6;
case 7:
return oa7;
case 8:
return oa8;
case 9:
return oa9;
case 10:
return oa10;
case 11:
return oa11;
case 12:
return oa12;
case 13:
return oa13;
case 14:
return oa14;
case 15:
return oa15;
case 16:
return oa16;
default:
return null;
}
}
@Override
public void log(Object s1) {
if (isSynchronized) {
synchronized(this) {
oa1[0] = s1;
log(oa1);
}
} else {
oa1[0] = s1;
log(oa1);
}
}
private final Object[] oa1 = new Object[1];
@Override
public void log(Object s1, Object s2) {
if (isSynchronized) {
synchronized(this) {
oa2[0] = s1;
oa2[1] = s2;
log(oa2);
}
} else {
oa2[0] = s1;
oa2[1] = s2;
log(oa2);
}
}
private Object[] oa2 = new Object[2];
@Override
public void log(Object s1, Object s2, Object s3) {
if (isSynchronized) {
synchronized(this) {
oa3[0] = s1;
oa3[1] = s2;
oa3[2] = s3;
log(oa3);
}
} else {
oa3[0] = s1;
oa3[1] = s2;
oa3[2] = s3;
log(oa3);
}
}
private Object[] oa3 = new Object[3];
@Override
public void log(Object s1, Object s2, Object s3, Object s4) {
if (isSynchronized) {
synchronized(this) {
oa4[0] = s1;
oa4[1] = s2;
oa4[2] = s3;
oa4[3] = s4;
log(oa4);
}
} else {
oa4[0] = s1;
oa4[1] = s2;
oa4[2] = s3;
oa4[3] = s4;
log(oa4);
}
}
private Object[] oa4 = new Object[4];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5) {
if (isSynchronized) {
synchronized(this) {
oa5[0] = s1;
oa5[1] = s2;
oa5[2] = s3;
oa5[3] = s4;
oa5[4] = s5;
log(oa5);
}
} else {
oa5[0] = s1;
oa5[1] = s2;
oa5[2] = s3;
oa5[3] = s4;
oa5[4] = s5;
log(oa5);
}
}
private Object[] oa5 = new Object[5];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6) {
if (isSynchronized) {
synchronized(this) {
oa6[0] = s1;
oa6[1] = s2;
oa6[2] = s3;
oa6[3] = s4;
oa6[4] = s5;
oa6[5] = s6;
log(oa6);
}
} else {
oa6[0] = s1;
oa6[1] = s2;
oa6[2] = s3;
oa6[3] = s4;
oa6[4] = s5;
oa6[5] = s6;
log(oa6);
}
}
private Object[] oa6 = new Object[6];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7) {
if (isSynchronized) {
synchronized(this) {
oa7[0] = s1;
oa7[1] = s2;
oa7[2] = s3;
oa7[3] = s4;
oa7[4] = s5;
oa7[5] = s6;
oa7[6] = s7;
log(oa7);
}
} else {
oa7[0] = s1;
oa7[1] = s2;
oa7[2] = s3;
oa7[3] = s4;
oa7[4] = s5;
oa7[5] = s6;
oa7[6] = s7;
log(oa7);
}
}
private Object[] oa7 = new Object[7];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8) {
if (isSynchronized) {
synchronized(this) {
oa8[0] = s1;
oa8[1] = s2;
oa8[2] = s3;
oa8[3] = s4;
oa8[4] = s5;
oa8[5] = s6;
oa8[6] = s7;
oa8[7] = s8;
log(oa8);
}
} else {
oa8[0] = s1;
oa8[1] = s2;
oa8[2] = s3;
oa8[3] = s4;
oa8[4] = s5;
oa8[5] = s6;
oa8[6] = s7;
oa8[7] = s8;
log(oa8);
}
}
private Object[] oa8 = new Object[8];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9) {
if (isSynchronized) {
synchronized(this) {
oa9[0] = s1;
oa9[1] = s2;
oa9[2] = s3;
oa9[3] = s4;
oa9[4] = s5;
oa9[5] = s6;
oa9[6] = s7;
oa9[7] = s8;
oa9[8] = s9;
log(oa9);
}
} else {
oa9[0] = s1;
oa9[1] = s2;
oa9[2] = s3;
oa9[3] = s4;
oa9[4] = s5;
oa9[5] = s6;
oa9[6] = s7;
oa9[7] = s8;
oa9[8] = s9;
log(oa9);
}
}
private Object[] oa9 = new Object[9];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9, Object s10) {
if (isSynchronized) {
synchronized(this) {
oa10[0] = s1;
oa10[1] = s2;
oa10[2] = s3;
oa10[3] = s4;
oa10[4] = s5;
oa10[5] = s6;
oa10[6] = s7;
oa10[7] = s8;
oa10[8] = s9;
oa10[9] = s10;
log(oa10);
}
} else {
oa10[0] = s1;
oa10[1] = s2;
oa10[2] = s3;
oa10[3] = s4;
oa10[4] = s5;
oa10[5] = s6;
oa10[6] = s7;
oa10[7] = s8;
oa10[8] = s9;
oa10[9] = s10;
log(oa10);
}
}
private Object[] oa10 = new Object[10];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9, Object s10, Object s11) {
if (isSynchronized) {
synchronized(this) {
oa11[0] = s1;
oa11[1] = s2;
oa11[2] = s3;
oa11[3] = s4;
oa11[4] = s5;
oa11[5] = s6;
oa11[6] = s7;
oa11[7] = s8;
oa11[8] = s9;
oa11[9] = s10;
oa11[10] = s11;
log(oa11);
}
} else {
oa11[0] = s1;
oa11[1] = s2;
oa11[2] = s3;
oa11[3] = s4;
oa11[4] = s5;
oa11[5] = s6;
oa11[6] = s7;
oa11[7] = s8;
oa11[8] = s9;
oa11[9] = s10;
oa11[10] = s11;
log(oa11);
}
}
private Object[] oa11 = new Object[11];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9, Object s10, Object s11, Object s12) {
if (isSynchronized) {
synchronized(this) {
oa12[0] = s1;
oa12[1] = s2;
oa12[2] = s3;
oa12[3] = s4;
oa12[4] = s5;
oa12[5] = s6;
oa12[6] = s7;
oa12[7] = s8;
oa12[8] = s9;
oa12[9] = s10;
oa12[10] = s11;
oa12[11] = s12;
log(oa12);
}
} else {
oa12[0] = s1;
oa12[1] = s2;
oa12[2] = s3;
oa12[3] = s4;
oa12[4] = s5;
oa12[5] = s6;
oa12[6] = s7;
oa12[7] = s8;
oa12[8] = s9;
oa12[9] = s10;
oa12[10] = s11;
oa12[11] = s12;
log(oa12);
}
}
private Object[] oa12 = new Object[12];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9, Object s10, Object s11, Object s12, Object s13) {
if (isSynchronized) {
synchronized(this) {
oa13[0] = s1;
oa13[1] = s2;
oa13[2] = s3;
oa13[3] = s4;
oa13[4] = s5;
oa13[5] = s6;
oa13[6] = s7;
oa13[7] = s8;
oa13[8] = s9;
oa13[9] = s10;
oa13[10] = s11;
oa13[11] = s12;
oa13[12] = s13;
log(oa13);
}
} else {
oa13[0] = s1;
oa13[1] = s2;
oa13[2] = s3;
oa13[3] = s4;
oa13[4] = s5;
oa13[5] = s6;
oa13[6] = s7;
oa13[7] = s8;
oa13[8] = s9;
oa13[9] = s10;
oa13[10] = s11;
oa13[11] = s12;
oa13[12] = s13;
log(oa13);
}
}
private Object[] oa13 = new Object[13];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9, Object s10, Object s11, Object s12, Object s13, Object s14) {
if (isSynchronized) {
synchronized(this) {
oa14[0] = s1;
oa14[1] = s2;
oa14[2] = s3;
oa14[3] = s4;
oa14[4] = s5;
oa14[5] = s6;
oa14[6] = s7;
oa14[7] = s8;
oa14[8] = s9;
oa14[9] = s10;
oa14[10] = s11;
oa14[11] = s12;
oa14[12] = s13;
oa14[13] = s14;
log(oa14);
}
} else {
oa14[0] = s1;
oa14[1] = s2;
oa14[2] = s3;
oa14[3] = s4;
oa14[4] = s5;
oa14[5] = s6;
oa14[6] = s7;
oa14[7] = s8;
oa14[8] = s9;
oa14[9] = s10;
oa14[10] = s11;
oa14[11] = s12;
oa14[12] = s13;
oa14[13] = s14;
log(oa14);
}
}
private Object[] oa14 = new Object[14];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9, Object s10, Object s11, Object s12, Object s13, Object s14, Object s15) {
if (isSynchronized) {
synchronized(this) {
oa15[0] = s1;
oa15[1] = s2;
oa15[2] = s3;
oa15[3] = s4;
oa15[4] = s5;
oa15[5] = s6;
oa15[6] = s7;
oa15[7] = s8;
oa15[8] = s9;
oa15[9] = s10;
oa15[10] = s11;
oa15[11] = s12;
oa15[12] = s13;
oa15[13] = s14;
oa15[14] = s15;
log(oa15);
}
} else {
oa15[0] = s1;
oa15[1] = s2;
oa15[2] = s3;
oa15[3] = s4;
oa15[4] = s5;
oa15[5] = s6;
oa15[6] = s7;
oa15[7] = s8;
oa15[8] = s9;
oa15[9] = s10;
oa15[10] = s11;
oa15[11] = s12;
oa15[12] = s13;
oa15[13] = s14;
oa15[14] = s15;
log(oa15);
}
}
private Object[] oa15 = new Object[15];
@Override
public void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9, Object s10, Object s11, Object s12, Object s13, Object s14, Object s15, Object s16) {
if (isSynchronized) {
synchronized(this) {
oa16[0] = s1;
oa16[1] = s2;
oa16[2] = s3;
oa16[3] = s4;
oa16[4] = s5;
oa16[5] = s6;
oa16[6] = s7;
oa16[7] = s8;
oa16[8] = s9;
oa16[9] = s10;
oa16[10] = s11;
oa16[11] = s12;
oa16[12] = s13;
oa16[13] = s14;
oa16[14] = s15;
oa16[15] = s16;
log(oa16);
}
} else {
oa16[0] = s1;
oa16[1] = s2;
oa16[2] = s3;
oa16[3] = s4;
oa16[4] = s5;
oa16[5] = s6;
oa16[6] = s7;
oa16[7] = s8;
oa16[8] = s9;
oa16[9] = s10;
oa16[10] = s11;
oa16[11] = s12;
oa16[12] = s13;
oa16[13] = s14;
oa16[14] = s15;
oa16[15] = s16;
log(oa16);
}
}
private Object[] oa16 = new Object[16];
private final LogEvent getLogEvent() {
if (!isAsynchronous) {
return LogEventUtils.getLogEvent();
} else {
return AsyncThread.getLogEvent(this);
}
}
@Override
public LogMessageBuilder add(char[] x) {
if (!isAsynchronous) {
getLogEvent().add(x);
} else {
getLogEvent().addCopy(x);
}
return this;
}
@Override
public LogMessageBuilder add(byte[] x) {
if (!isAsynchronous) {
getLogEvent().add(x);
} else {
getLogEvent().addCopy(x);
}
return this;
}
@Override
public LogMessageBuilder add(long x) {
getLogEvent().add(x);
return this;
}
@Override
public LogMessageBuilder add(int x) {
getLogEvent().add(x);
return this;
}
@Override
public LogMessageBuilder add(double x) {
getLogEvent().add(x);
return this;
}
@Override
public LogMessageBuilder add(float x) {
getLogEvent().add(x);
return this;
}
@Override
public LogMessageBuilder add(byte x) {
getLogEvent().add(x);
return this;
}
@Override
public LogMessageBuilder add(short x) {
getLogEvent().add(x);
return this;
}
@Override
public LogMessageBuilder add(char x) {
getLogEvent().add(x);
return this;
}
@Override
public LogMessageBuilder add(boolean x) {
getLogEvent().add(x);
return this;
}
@Override
public LogMessageBuilder add(Object o) {
getLogEvent().add(o);
return this;
}
@Override
public LogMessageBuilder add(StringBuilder sb) {
if (!isAsynchronous) {
getLogEvent().add(sb);
} else {
getLogEvent().addCopy(sb);
}
return this;
}
@Override
public LogMessageBuilder add(AsciiEncodable cs) {
if (!isAsynchronous) {
getLogEvent().add(cs);
} else {
getLogEvent().addCopy(cs);
}
return this;
}
@Override
public void flush() {
LogEvent logEvent = getLogEvent();
logEvent.setLogger(this);
if (!isAsynchronous) {
logEvent.log();
} else {
AsyncThread.flush(Log.isProducerLazySet());
}
}
}