org.mentalog
Class ExtendedDefaultLogger

java.lang.Object
  extended by org.mentalog.ExtendedDefaultLogger
All Implemented Interfaces:
AsynchronousLogger, Logger, LogMessageBuilder, VarargsOverloading

public class ExtendedDefaultLogger
extends Object


Field Summary
protected  ByteBuffer buffer
           
protected  FileChannel fileChannel
           
protected  File outputFile
           
protected  RandomAccessFile raf
           
 
Constructor Summary
ExtendedDefaultLogger(PrintStream stream, String prefix, Timestamper timestamper, boolean isSynchronized, byte[] color, List<Encoder> encoders, Log level, boolean isAsynchronous)
           
ExtendedDefaultLogger(String dir, String filename, Timestamper timestamper, boolean isSynchronized, boolean isMemoryMapped, int memoryMappedBufferSize, List<Encoder> encoders, Log level, boolean isAsynchronous)
           
ExtendedDefaultLogger(String filename, Timestamper timestamper, boolean isSynchronized, boolean isMemoryMapped, int memoryMappedBufferSize, List<Encoder> encoders, Log level, boolean isAsynchronous)
           
 
Method Summary
 LogMessageBuilder add(AsciiEncodable cs)
           
 LogMessageBuilder add(boolean x)
           
 LogMessageBuilder add(byte x)
           
 LogMessageBuilder add(byte[] x)
           
 LogMessageBuilder add(char x)
           
 LogMessageBuilder add(char[] x)
           
 LogMessageBuilder add(double x)
           
 LogMessageBuilder add(float x)
           
 LogMessageBuilder add(int x)
           
 LogMessageBuilder add(long x)
           
 LogMessageBuilder add(Object o)
           
 LogMessageBuilder add(short x)
           
 LogMessageBuilder add(StringBuilder sb)
           
 void addInterceptor(Interceptor interceptor)
          Add a log interceptor, so you can intercept the bytebuffer that is about to be written by the log.
 void close()
          Close this log.
 void close(boolean async)
           
protected  void closeAllMemoryMappedBuffers(boolean forceBuffers)
           
protected  MappedByteBuffer createMappedByteBuffer(File file, int size)
           
 void enable(boolean b)
           
 void flush()
           
protected  void flushForMemoryMappedBuffer()
           
 Object[] getVarargs(int size)
           
protected  void header(long timestamp)
           
 boolean isClosed()
          Is this log closed?
 boolean isEnabled()
          Is the log enabled, in other words, will a call to log() log anything? This method is useful if you don't want to process the log() method arguments.
static boolean isExtension()
           
 void log(boolean async, Object... objects)
           
 void log(Object... objects)
          Log as many objects as you want.
 void log(Object s1)
           
 void log(Object s1, Object s2)
           
 void log(Object s1, Object s2, Object s3)
           
 void log(Object s1, Object s2, Object s3, Object s4)
           
 void log(Object s1, Object s2, Object s3, Object s4, Object s5)
           
 void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6)
           
 void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7)
           
 void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8)
           
 void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9)
           
 void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9, Object s10)
           
 void log(Object s1, Object s2, Object s3, Object s4, Object s5, Object s6, Object s7, Object s8, Object s9, Object s10, Object s11)
           
 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)
           
 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)
           
 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)
           
 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)
           
 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)
           
protected  void printTopHeader(boolean newFile)
           
 void removeInterceptor(Interceptor interceptor)
          Remove a log interceptor.
 void roll()
          Roll the log file.
 void roll(boolean async)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buffer

protected ByteBuffer buffer

fileChannel

protected FileChannel fileChannel

raf

protected RandomAccessFile raf

outputFile

protected File outputFile
Constructor Detail

ExtendedDefaultLogger

public ExtendedDefaultLogger(PrintStream stream,
                             String prefix,
                             Timestamper timestamper,
                             boolean isSynchronized,
                             byte[] color,
                             List<Encoder> encoders,
                             Log level,
                             boolean isAsynchronous)

ExtendedDefaultLogger

public ExtendedDefaultLogger(String dir,
                             String filename,
                             Timestamper timestamper,
                             boolean isSynchronized,
                             boolean isMemoryMapped,
                             int memoryMappedBufferSize,
                             List<Encoder> encoders,
                             Log level,
                             boolean isAsynchronous)
                      throws IOException
Throws:
IOException

ExtendedDefaultLogger

public ExtendedDefaultLogger(String filename,
                             Timestamper timestamper,
                             boolean isSynchronized,
                             boolean isMemoryMapped,
                             int memoryMappedBufferSize,
                             List<Encoder> encoders,
                             Log level,
                             boolean isAsynchronous)
                      throws IOException
Throws:
IOException
Method Detail

isExtension

public static boolean isExtension()

createMappedByteBuffer

protected MappedByteBuffer createMappedByteBuffer(File file,
                                                  int size)

toString

public String toString()
Overrides:
toString in class Object

addInterceptor

public void addInterceptor(Interceptor interceptor)
Description copied from interface: Logger
Add a log interceptor, so you can intercept the bytebuffer that is about to be written by the log.

Specified by:
addInterceptor in interface Logger
Parameters:
interceptor - The log interceptor

removeInterceptor

public void removeInterceptor(Interceptor interceptor)
Description copied from interface: Logger
Remove a log interceptor.

Specified by:
removeInterceptor in interface Logger
Parameters:
interceptor - The log interceptor

close

public void close()
Description copied from interface: Logger
Close this log. If this log is file-based, the file will be closed.

Specified by:
close in interface Logger

close

public void close(boolean async)
Specified by:
close in interface AsynchronousLogger

isClosed

public boolean isClosed()
Description copied from interface: Logger
Is this log closed?

Specified by:
isClosed in interface Logger
Returns:
true if closed

enable

public void enable(boolean b)

roll

public void roll()
Description copied from interface: Logger
Roll the log file. It appends -ddMMyyyy-HHmmss to the current log file and opens a new one.

Specified by:
roll in interface Logger

roll

public void roll(boolean async)
Specified by:
roll in interface AsynchronousLogger

closeAllMemoryMappedBuffers

protected void closeAllMemoryMappedBuffers(boolean forceBuffers)

printTopHeader

protected void printTopHeader(boolean newFile)

flushForMemoryMappedBuffer

protected void flushForMemoryMappedBuffer()

header

protected void header(long timestamp)

log

public void log(Object... objects)
Description copied from interface: Logger
Log as many objects as you want. The method toString() will be called for each object passed here unless you are using a string encoder for the object. The objects are logged with a space (' ') between them.

Specified by:
log in interface Logger
Parameters:
objects - The list of objects to log.

log

public void log(boolean async,
                Object... objects)
Specified by:
log in interface AsynchronousLogger

isEnabled

public boolean isEnabled()
Description copied from interface: Logger
Is the log enabled, in other words, will a call to log() log anything? This method is useful if you don't want to process the log() method arguments. If you don't care, just call log and if the log is not enabled it will not print anything.

Specified by:
isEnabled in interface Logger
Returns:
true if enabled

getVarargs

public final Object[] getVarargs(int size)
Specified by:
getVarargs in interface VarargsOverloading

log

public void log(Object s1)
Specified by:
log in interface VarargsOverloading

log

public void log(Object s1,
                Object s2)
Specified by:
log in interface VarargsOverloading

log

public void log(Object s1,
                Object s2,
                Object s3)
Specified by:
log in interface VarargsOverloading

log

public void log(Object s1,
                Object s2,
                Object s3,
                Object s4)
Specified by:
log in interface VarargsOverloading

log

public void log(Object s1,
                Object s2,
                Object s3,
                Object s4,
                Object s5)
Specified by:
log in interface VarargsOverloading

log

public void log(Object s1,
                Object s2,
                Object s3,
                Object s4,
                Object s5,
                Object s6)
Specified by:
log in interface VarargsOverloading

log

public void log(Object s1,
                Object s2,
                Object s3,
                Object s4,
                Object s5,
                Object s6,
                Object s7)
Specified by:
log in interface VarargsOverloading

log

public void log(Object s1,
                Object s2,
                Object s3,
                Object s4,
                Object s5,
                Object s6,
                Object s7,
                Object s8)
Specified by:
log in interface VarargsOverloading

log

public void log(Object s1,
                Object s2,
                Object s3,
                Object s4,
                Object s5,
                Object s6,
                Object s7,
                Object s8,
                Object s9)
Specified by:
log in interface VarargsOverloading

log

public void log(Object s1,
                Object s2,
                Object s3,
                Object s4,
                Object s5,
                Object s6,
                Object s7,
                Object s8,
                Object s9,
                Object s10)
Specified by:
log in interface VarargsOverloading

log

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)
Specified by:
log in interface VarargsOverloading

log

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)
Specified by:
log in interface VarargsOverloading

log

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)
Specified by:
log in interface VarargsOverloading

log

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)
Specified by:
log in interface VarargsOverloading

log

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)
Specified by:
log in interface VarargsOverloading

log

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)
Specified by:
log in interface VarargsOverloading

add

public LogMessageBuilder add(char[] x)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(byte[] x)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(long x)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(int x)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(double x)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(float x)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(byte x)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(short x)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(char x)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(boolean x)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(Object o)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(StringBuilder sb)
Specified by:
add in interface LogMessageBuilder

add

public LogMessageBuilder add(AsciiEncodable cs)
Specified by:
add in interface LogMessageBuilder

flush

public void flush()
Specified by:
flush in interface LogMessageBuilder


Copyright © 2013. All Rights Reserved.