Modifier and Type | Class and Description |
---|---|
static interface |
DefaultFormatter.FormatFlag
|
Modifier and Type | Field and Description |
---|---|
static int |
FLAG_FMT_JSON
|
static int |
FLAG_FMT_POJO
|
static int |
FLAG_FMT_THROWABLE
|
Constructor and Description |
---|
DefaultFormatter()
Create a formatter with all supported type format enabled.
|
DefaultFormatter(int... enabledTypes)
Create a formatter which only support specified types.
|
Modifier and Type | Method and Description |
---|---|
String |
format(String msg,
Object... params)
Format msg with params and return.
|
public static final int FLAG_FMT_JSON
public static final int FLAG_FMT_POJO
public static final int FLAG_FMT_THROWABLE
public DefaultFormatter()
public DefaultFormatter(int... enabledTypes)
enabledTypes
- types to format.public String format(String msg, Object... params) throws Exception
Formatter
NOTE VERY IMPORTANT: Sub implementation can decide whether discard one or more arguments, so make sure you are using right Formatter in right usage.
format
in
interface Formatter
msg
- msg to be formatted. If this is null or empty but params
provided, params
still should be formatted.
params
- params to format msg. maybe empty.Exception
- any type of
Exception can be thrown by implementation when
format failed.