org.mentalog
Enum Log

java.lang.Object
  extended by java.lang.Enum<Log>
      extended by org.mentalog.Log
All Implemented Interfaces:
Serializable, Comparable<Log>, AsynchronousLogger, Logger, LogMessageBuilder, VarargsOverloading

public enum Log
extends Enum<Log>
implements Logger, LogMessageBuilder

An enumeration with a log for each level. The levels are: Debug, Info, Warn, Error, Alert, Fatal. Each level implement the Logger interface. You can also use the static method createLogger to create other logs not related to any level. Refer to: http://mentalog.soliveirajr.com for documentations, recipes and more.

Author:
Sergio Oliveira Jr. - sergio.oliveira.jr@gmail.com

Enum Constant Summary
Alert
           
Debug
           
Error
           
Fatal
           
Info
           
Warn
           
 
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)
           
static void add(Encoder encoder)
           
 LogMessageBuilder add(float x)
           
 LogMessageBuilder add(int x)
           
static void add(Interceptor interceptor)
           
 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)
           
static void closeAll()
           
static Logger createLogger(String dir, String filename, boolean isSynchronized, boolean isAsynchronous)
           
static Logger createLogger(String dir, String filename, boolean isSynchronized, boolean isMemoryMapped, int memoryMappedBufferSize, boolean isAsynchronous)
           
static Logger createLogger(String dir, String filename, boolean isSynchronized, List<Encoder> encoders, boolean isAsynchronous)
           
static Logger createLogger(String dir, String filename, Timestamper timestamper, boolean isSynchronized, boolean isAsynchronous)
           
static Logger createLogger(String dir, String filename, Timestamper timestamper, boolean isSynchronized, boolean isMemoryMapped, int memoryMappedBufferSize, List<Encoder> encoders, boolean isAsynchronous)
           
static Logger createMemoryMappedLogger(String dir, String filename, boolean isSynchronized, boolean isAsynchronous)
           
static Logger createMemoryMappedLogger(String dir, String filename, boolean isSynchronized, int memoryMappedBufferSize, boolean isAsynchronous)
           
static Logger createMemoryMappedLogger(String dir, String filename, boolean isSynchronized, List<Encoder> encoders, boolean isAsynchronous)
           
static Logger createMemoryMappedLogger(String dir, String filename, boolean isSynchronized, List<Encoder> encoders, int memoryMappedBufferSize, boolean isAsynchronous)
           
static Logger createMemoryMappedLogger(String dir, String filename, Timestamper timestamper, boolean isSynchronized, boolean isAsynchronous)
           
static Logger createMemoryMappedLogger(String dir, String filename, Timestamper timestamper, boolean isSynchronized, int memoryMappedBufferSize, boolean isAsynchronous)
           
 void enable(Boolean flag)
           
static void enableAll(Boolean flag)
           
 void flush()
           
static Log fromString(String s)
           
static int getBufferSize()
           
static String getDir()
           
static List<Encoder> getEncoders()
           
static String[] getFilter()
           
static Log getLevel()
           
static int getMemoryMappedBufferSize()
           
static float getMemoryMappedBufferThreshold()
           
static Log getShowBypassedConfigLevel()
           
static Timestamper getTimestamper()
           
static TimeZone getTimeZone()
           
 Object[] getVarargs(int size)
           
static boolean isAlertOnBufferRoll()
           
static boolean isBenchmark()
           
static boolean isCacheOnBufferRoll()
           
 boolean isClosed()
          Is this log closed?
static boolean isColors()
           
static boolean isConsole()
           
static boolean isConsumerLazySet()
           
 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 isExtended()
           
static boolean isFile()
           
static boolean isForceOnBufferRoll()
           
static boolean isForceOnClose()
           
static boolean isNoSpaceAfterEqualSign()
           
static boolean isNoSpaceBetweenObjects()
           
 boolean isOn(Log level)
           
static boolean isProducerLazySet()
           
static boolean isShowBypassedConfig()
           
static boolean isShowClassAndLineNumber()
           
static boolean isSynchronized()
           
 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)
           
 void logBenchmark()
           
static void main(String[] args)
           
static void remove(Interceptor interceptor)
           
 void removeInterceptor(Interceptor interceptor)
          Remove a log interceptor.
 void roll()
          Roll the log file.
 void roll(boolean async)
           
static void setAlertOnBufferRoll(boolean b)
           
static void setAsynchronousConsumerPriority(int x)
           
static void setAsynchronousConsumerWaitStrategy(org.mentaqueue.wait.WaitStrategy strategy)
           
static void setAsynchronousProducerWaitStrategy(org.mentaqueue.wait.WaitStrategy strategy)
           
static void setAsynchronousQueueCapacity(int x)
           
static void setBenchmark(boolean flag)
           
static void setBufferSize(int size)
           
static void setCacheOnBufferRoll(boolean b)
           
 void setColor(int color)
           
static void setColors(boolean b)
           
static void setConsole(boolean flag)
           
 void setConsumerLazySet(boolean flag)
           
static void setDir(String dir)
           
static void setEncoders(List<Encoder> encs)
           
static void setFile(boolean flag)
           
 void setFilename(String filename)
           
static void setFilter(String filter)
           
static void setForceOnBufferRoll(boolean b)
           
static void setForceOnClose(boolean b)
           
static void setLevel(Log level)
           
static void setMemoryMappedBufferSize(int size)
           
static void setMemoryMappedBufferThreshold(float f)
           
static void setNoSpaceAfterEqualSign(boolean flag)
           
static void setNoSpaceBetweenObjects(boolean flag)
           
static void setProcToBindConsumer(int x)
           
 void setProducerLazySet(boolean flag)
           
static void setShowBypassedConfig(boolean flag, Log level)
           
static void setShowClassAndLineNumber(boolean flag)
           
static void setSynchronized(boolean flag)
           
static void setTimestamper(Timestamper ts)
           
static void setTimeZone(TimeZone tz)
           
static void stop()
           
static StringBuilder to_sb(boolean b)
           
static StringBuilder to_sb(byte b)
           
static StringBuilder to_sb(char c)
           
static StringBuilder to_sb(double x)
           
static StringBuilder to_sb(float f)
           
static StringBuilder to_sb(int x)
           
static StringBuilder to_sb(long x)
           
static StringBuilder to_sb(short s)
           
static Log valueOf(String name)
          Returns the enum constant of this type with the specified name.
static Log[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

Debug

public static final Log Debug

Info

public static final Log Info

Warn

public static final Log Warn

Error

public static final Log Error

Alert

public static final Log Alert

Fatal

public static final Log Fatal
Method Detail

values

public static Log[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (Log c : Log.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Log valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

setAsynchronousProducerWaitStrategy

public static final void setAsynchronousProducerWaitStrategy(org.mentaqueue.wait.WaitStrategy strategy)

isExtended

public static final boolean isExtended()

setAsynchronousConsumerWaitStrategy

public static final void setAsynchronousConsumerWaitStrategy(org.mentaqueue.wait.WaitStrategy strategy)

stop

public static void stop()

fromString

public static Log fromString(String s)

isProducerLazySet

public static final boolean isProducerLazySet()

setProducerLazySet

public final void setProducerLazySet(boolean flag)

isConsumerLazySet

public static final boolean isConsumerLazySet()

setConsumerLazySet

public final void setConsumerLazySet(boolean flag)

isCacheOnBufferRoll

public static final boolean isCacheOnBufferRoll()

isAlertOnBufferRoll

public static final boolean isAlertOnBufferRoll()

isForceOnBufferRoll

public static final boolean isForceOnBufferRoll()

isForceOnClose

public static final boolean isForceOnClose()

setProcToBindConsumer

public static final void setProcToBindConsumer(int x)

setAsynchronousQueueCapacity

public static final void setAsynchronousQueueCapacity(int x)

setAsynchronousConsumerPriority

public static final void setAsynchronousConsumerPriority(int x)

setCacheOnBufferRoll

public static final void setCacheOnBufferRoll(boolean b)

setAlertOnBufferRoll

public static final void setAlertOnBufferRoll(boolean b)

setForceOnBufferRoll

public static final void setForceOnBufferRoll(boolean b)

setForceOnClose

public static final void setForceOnClose(boolean b)

getMemoryMappedBufferThreshold

public static final float getMemoryMappedBufferThreshold()

setMemoryMappedBufferThreshold

public static final void setMemoryMappedBufferThreshold(float f)

getMemoryMappedBufferSize

public static int getMemoryMappedBufferSize()

setMemoryMappedBufferSize

public static void setMemoryMappedBufferSize(int size)

getBufferSize

public static int getBufferSize()

setBufferSize

public static void setBufferSize(int size)

isBenchmark

public static boolean isBenchmark()

setBenchmark

public static void setBenchmark(boolean flag)

getFilter

public static String[] getFilter()

setFilter

public static void setFilter(String filter)

isShowClassAndLineNumber

public static boolean isShowClassAndLineNumber()

setShowClassAndLineNumber

public static void setShowClassAndLineNumber(boolean flag)

isNoSpaceBetweenObjects

public static boolean isNoSpaceBetweenObjects()

setNoSpaceBetweenObjects

public static void setNoSpaceBetweenObjects(boolean flag)

isNoSpaceAfterEqualSign

public static boolean isNoSpaceAfterEqualSign()

setNoSpaceAfterEqualSign

public static void setNoSpaceAfterEqualSign(boolean flag)

getEncoders

public static List<Encoder> getEncoders()

add

public static void add(Encoder encoder)

setEncoders

public static void setEncoders(List<Encoder> encs)

isColors

public static boolean isColors()

setColors

public static void setColors(boolean b)

isSynchronized

public static boolean isSynchronized()

setSynchronized

public static void setSynchronized(boolean flag)

isConsole

public static boolean isConsole()

setLevel

public static void setLevel(Log level)

getLevel

public static Log getLevel()

setShowBypassedConfig

public static void setShowBypassedConfig(boolean flag,
                                         Log level)

isShowBypassedConfig

public static boolean isShowBypassedConfig()

getShowBypassedConfigLevel

public static Log getShowBypassedConfigLevel()

getTimestamper

public static Timestamper getTimestamper()

setConsole

public static void setConsole(boolean flag)

setFile

public static void setFile(boolean flag)

isFile

public static boolean isFile()

setTimestamper

public static void setTimestamper(Timestamper ts)

setTimeZone

public static void setTimeZone(TimeZone tz)

getTimeZone

public static TimeZone getTimeZone()

setDir

public static void setDir(String dir)

getDir

public static String getDir()

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

setColor

public void setColor(int color)

setFilename

public void setFilename(String filename)

closeAll

public static void closeAll()

add

public static void add(Interceptor interceptor)

remove

public static void remove(Interceptor interceptor)

close

public final 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

logBenchmark

public void logBenchmark()

isOn

public boolean isOn(Log level)

enableAll

public static void enableAll(Boolean flag)

enable

public final void enable(Boolean flag)

isEnabled

public final 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

createLogger

public static Logger createLogger(String dir,
                                  String filename,
                                  Timestamper timestamper,
                                  boolean isSynchronized,
                                  boolean isAsynchronous)

createLogger

public static Logger createLogger(String dir,
                                  String filename,
                                  boolean isSynchronized,
                                  boolean isAsynchronous)

createLogger

public static Logger createLogger(String dir,
                                  String filename,
                                  boolean isSynchronized,
                                  List<Encoder> encoders,
                                  boolean isAsynchronous)

createMemoryMappedLogger

public static Logger createMemoryMappedLogger(String dir,
                                              String filename,
                                              Timestamper timestamper,
                                              boolean isSynchronized,
                                              boolean isAsynchronous)

createMemoryMappedLogger

public static Logger createMemoryMappedLogger(String dir,
                                              String filename,
                                              boolean isSynchronized,
                                              boolean isAsynchronous)

createMemoryMappedLogger

public static Logger createMemoryMappedLogger(String dir,
                                              String filename,
                                              boolean isSynchronized,
                                              List<Encoder> encoders,
                                              boolean isAsynchronous)

createMemoryMappedLogger

public static Logger createMemoryMappedLogger(String dir,
                                              String filename,
                                              Timestamper timestamper,
                                              boolean isSynchronized,
                                              int memoryMappedBufferSize,
                                              boolean isAsynchronous)

createMemoryMappedLogger

public static Logger createMemoryMappedLogger(String dir,
                                              String filename,
                                              boolean isSynchronized,
                                              int memoryMappedBufferSize,
                                              boolean isAsynchronous)

createMemoryMappedLogger

public static Logger createMemoryMappedLogger(String dir,
                                              String filename,
                                              boolean isSynchronized,
                                              List<Encoder> encoders,
                                              int memoryMappedBufferSize,
                                              boolean isAsynchronous)

createLogger

public static Logger createLogger(String dir,
                                  String filename,
                                  boolean isSynchronized,
                                  boolean isMemoryMapped,
                                  int memoryMappedBufferSize,
                                  boolean isAsynchronous)

createLogger

public static Logger createLogger(String dir,
                                  String filename,
                                  Timestamper timestamper,
                                  boolean isSynchronized,
                                  boolean isMemoryMapped,
                                  int memoryMappedBufferSize,
                                  List<Encoder> encoders,
                                  boolean isAsynchronous)

roll

public final 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

log

public final 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.

main

public static void main(String[] args)

log

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

close

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

roll

public void roll(boolean async)
Specified by:
roll 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

log

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

log

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

log

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

log

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

log

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

log

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

log

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

log

public final 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 final 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 final 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 final 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 final 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 final 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 final 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 final 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 final 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

to_sb

public static final StringBuilder to_sb(int x)

to_sb

public static final StringBuilder to_sb(long x)

to_sb

public static final StringBuilder to_sb(byte b)

to_sb

public static final StringBuilder to_sb(short s)

to_sb

public static final StringBuilder to_sb(double x)

to_sb

public static final StringBuilder to_sb(boolean b)

to_sb

public static final StringBuilder to_sb(float f)

to_sb

public static final StringBuilder to_sb(char c)

add

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

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

flush

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

getVarargs

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


Copyright © 2013. All Rights Reserved.