Top Description Inners Fields Constructors Methods
org.springframework.core.log

public abstract Class LogMessage

extends Object
implements CharSequence
Class Inheritance
All Implemented Interfaces
java.lang.CharSequence
Known Direct Subclasses
org.springframework.core.log.LogMessage.SupplierMessage, org.springframework.core.log.LogMessage.FormatMessage
Imports
java.util.function.Supplier, org.springframework.lang.Nullable, org.springframework.util.Assert

A simple log message type for use with Commons Logging, allowing for convenient lazy resolution of a given Supplier instance (typically bound to a lambda expression) or a printf-style format string (String#format) in its toString().
Authors
Juergen Hoeller, Sebastien Deleuze
Since
5.2
See Also
of(Supplier), format(String, Object), format(String, Object...), org.apache.commons.logging.Log#fatal(Object), org.apache.commons.logging.Log#error(Object), org.apache.commons.logging.Log#warn(Object), org.apache.commons.logging.Log#info(Object), org.apache.commons.logging.Log#debug(Object), org.apache.commons.logging.Log#trace(Object)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
private static class
private static class
private static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract String
public char
charAt(int
the index of the char value to be returned
index
)

Implements java.lang.CharSequence.charAt.

Returns the char value at the specified index.

public static LogMessage
format(String
the format string (following String#format rules)
format
,
Object
the argument (can be null)
arg1
)

Build a lazily formatted message from the given format string and argument.

public static LogMessage
format(String
the format string (following String#format rules)
format
,
Object
the first argument (can be null)
arg1
,
Object
the second argument (can be null)
arg2
)

Build a lazily formatted message from the given format string and arguments.

public static LogMessage
format(String
the format string (following String#format rules)
format
,
Object
the first argument (can be null)
arg1
,
Object
the second argument (can be null)
arg2
,
Object
the third argument (can be null)
arg3
)

Build a lazily formatted message from the given format string and arguments.

public static LogMessage
format(String
the format string (following String#format rules)
format
,
Object
the first argument (can be null)
arg1
,
Object
the second argument (can be null)
arg2
,
Object
the third argument (can be null)
arg3
,
Object
the fourth argument (can be null)
arg4
)

Build a lazily formatted message from the given format string and arguments.

public static LogMessage
format(String
the format string (following String#format rules)
format
,
Object...
the varargs array (can be null and can contain null elements)
args
)

Build a lazily formatted message from the given format string and varargs.

public int
length()

Implements java.lang.CharSequence.length.

Returns the length of this character sequence.

public static LogMessage
of(Supplier<? extends CharSequence>
the supplier (typically bound to a lambda expression)
supplier
)

Build a lazily resolving message from the given supplier.

public CharSequence
subSequence(int
the start index, inclusive
start
,
int
the end index, exclusive
end
)

Implements java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence.

public String
toString()

Overrides java.lang.Object.toString.

Implements java.lang.CharSequence.toString.

This will be called by the logging provider, potentially once per log target (therefore locally caching the result here).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

resultback to summary
private String result
Annotations
@Nullable

Constructor Detail

LogMessageback to summary
public LogMessage()

Method Detail

buildStringback to summary
pack-priv abstract String buildString()
charAtback to summary
public char charAt(int index)

Implements java.lang.CharSequence.charAt.

Doc from java.lang.CharSequence.charAt.

Returns the char value at the specified index. An index ranges from zero to length() - 1. The first char value of the sequence is at index zero, the next at index one, and so on, as for array indexing.

If the char value specified by the index is a surrogate, the surrogate value is returned.

Parameters
index:int

the index of the char value to be returned

Returns:char

the specified char value

Annotations
@Override
formatback to summary
public static LogMessage format(String format, Object arg1)

Build a lazily formatted message from the given format string and argument.

Parameters
format:String

the format string (following String#format rules)

arg1:Object

the argument (can be null)

See Also
String#format(String, Object...)
formatback to summary
public static LogMessage format(String format, Object arg1, Object arg2)

Build a lazily formatted message from the given format string and arguments.

Parameters
format:String

the format string (following String#format rules)

arg1:Object

the first argument (can be null)

arg2:Object

the second argument (can be null)

See Also
String#format(String, Object...)
formatback to summary
public static LogMessage format(String format, Object arg1, Object arg2, Object arg3)

Build a lazily formatted message from the given format string and arguments.

Parameters
format:String

the format string (following String#format rules)

arg1:Object

the first argument (can be null)

arg2:Object

the second argument (can be null)

arg3:Object

the third argument (can be null)

See Also
String#format(String, Object...)
formatback to summary
public static LogMessage format(String format, Object arg1, Object arg2, Object arg3, Object arg4)

Build a lazily formatted message from the given format string and arguments.

Parameters
format:String

the format string (following String#format rules)

arg1:Object

the first argument (can be null)

arg2:Object

the second argument (can be null)

arg3:Object

the third argument (can be null)

arg4:Object

the fourth argument (can be null)

See Also
String#format(String, Object...)
formatback to summary
public static LogMessage format(String format, Object... args)

Build a lazily formatted message from the given format string and varargs.

This varargs format() variant may be costly. You should therefore use the individual argument variants whenever possible; format(String, Object), format(String, Object, Object), etc.

Parameters
format:String

the format string (following String#format rules)

args:Object[]

the varargs array (can be null and can contain null elements)

See Also
String#format(String, Object...)
lengthback to summary
public int length()

Implements java.lang.CharSequence.length.

Doc from java.lang.CharSequence.length.

Returns the length of this character sequence. The length is the number of 16-bit chars in the sequence.

Returns:int

the number of chars in this sequence

Annotations
@Override
ofback to summary
public static LogMessage of(Supplier<? extends CharSequence> supplier)

Build a lazily resolving message from the given supplier.

Parameters
supplier:Supplier<? extends CharSequence>

the supplier (typically bound to a lambda expression)

See Also
toString()
subSequenceback to summary
public CharSequence subSequence(int start, int end)

Implements java.lang.CharSequence.subSequence.

Doc from java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence. The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.

Parameters
start:int

the start index, inclusive

end:int

the end index, exclusive

Returns:CharSequence

the specified subsequence

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements java.lang.CharSequence.toString.

This will be called by the logging provider, potentially once per log target (therefore locally caching the result here).

Returns:String

Doc from java.lang.CharSequence.toString.

a string consisting of exactly this sequence of characters

Annotations
@Override
org.springframework.core.log back to summary

private abstract Class LogMessage.FormatMessage

extends LogMessage
Class Inheritance
Known Direct Subclasses
org.springframework.core.log.LogMessage.FormatMessage1, org.springframework.core.log.LogMessage.FormatMessage2, org.springframework.core.log.LogMessage.FormatMessage3, org.springframework.core.log.LogMessage.FormatMessage4, org.springframework.core.log.LogMessage.FormatMessageX

Field Summary

Modifier and TypeField and Description
protected final String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from org.springframework.core.log.LogMessage:
buildStringcharAtformatformatformatformatformatlengthofsubSequencetoString

Field Detail

formatback to summary
protected final String format

Constructor Detail

FormatMessageback to summary
pack-priv FormatMessage(String format)
org.springframework.core.log back to summary

private final Class LogMessage.FormatMessage1

extends FormatMessage
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Object
Inherited from org.springframework.core.log.LogMessage.FormatMessage:
format

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected String

Field Detail

arg1back to summary
private final Object arg1
Annotations
@Nullable

Constructor Detail

FormatMessage1back to summary
pack-priv FormatMessage1(String format, Object arg1)

Method Detail

buildStringback to summary
protected String buildString()

Implements abstract org.springframework.core.log.LogMessage.buildString.

Annotations
@Override
org.springframework.core.log back to summary

private final Class LogMessage.FormatMessage2

extends FormatMessage
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Object
private final Object
Inherited from org.springframework.core.log.LogMessage.FormatMessage:
format

Constructor Summary

AccessConstructor and Description
pack-priv
FormatMessage2(String format, Object arg1, Object arg2)

Method Summary

Modifier and TypeMethod and Description
pack-priv String

Field Detail

arg1back to summary
private final Object arg1
Annotations
@Nullable
arg2back to summary
private final Object arg2
Annotations
@Nullable

Constructor Detail

FormatMessage2back to summary
pack-priv FormatMessage2(String format, Object arg1, Object arg2)

Method Detail

buildStringback to summary
pack-priv String buildString()

Implements abstract org.springframework.core.log.LogMessage.buildString.

Annotations
@Override
org.springframework.core.log back to summary

private final Class LogMessage.FormatMessage3

extends FormatMessage
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Object
private final Object
private final Object
Inherited from org.springframework.core.log.LogMessage.FormatMessage:
format

Constructor Summary

AccessConstructor and Description
pack-priv
FormatMessage3(String format, Object arg1, Object arg2, Object arg3)

Method Summary

Modifier and TypeMethod and Description
pack-priv String

Field Detail

arg1back to summary
private final Object arg1
Annotations
@Nullable
arg2back to summary
private final Object arg2
Annotations
@Nullable
arg3back to summary
private final Object arg3
Annotations
@Nullable

Constructor Detail

FormatMessage3back to summary
pack-priv FormatMessage3(String format, Object arg1, Object arg2, Object arg3)

Method Detail

buildStringback to summary
pack-priv String buildString()

Implements abstract org.springframework.core.log.LogMessage.buildString.

Annotations
@Override
org.springframework.core.log back to summary

private final Class LogMessage.FormatMessage4

extends FormatMessage
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Object
private final Object
private final Object
private final Object
Inherited from org.springframework.core.log.LogMessage.FormatMessage:
format

Constructor Summary

AccessConstructor and Description
pack-priv
FormatMessage4(String format, Object arg1, Object arg2, Object arg3, Object arg4)

Method Summary

Modifier and TypeMethod and Description
pack-priv String

Field Detail

arg1back to summary
private final Object arg1
Annotations
@Nullable
arg2back to summary
private final Object arg2
Annotations
@Nullable
arg3back to summary
private final Object arg3
Annotations
@Nullable
arg4back to summary
private final Object arg4
Annotations
@Nullable

Constructor Detail

FormatMessage4back to summary
pack-priv FormatMessage4(String format, Object arg1, Object arg2, Object arg3, Object arg4)

Method Detail

buildStringback to summary
pack-priv String buildString()

Implements abstract org.springframework.core.log.LogMessage.buildString.

Annotations
@Override
org.springframework.core.log back to summary

private final Class LogMessage.FormatMessageX

extends FormatMessage
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Object[]
Inherited from org.springframework.core.log.LogMessage.FormatMessage:
format

Constructor Summary

AccessConstructor and Description
pack-priv
FormatMessageX(String format, Object... args)

Method Summary

Modifier and TypeMethod and Description
pack-priv String

Field Detail

argsback to summary
private final Object[] args
Annotations
@Nullable

Constructor Detail

FormatMessageXback to summary
pack-priv FormatMessageX(String format, Object... args)

Method Detail

buildStringback to summary
pack-priv String buildString()

Implements abstract org.springframework.core.log.LogMessage.buildString.

Annotations
@Override
org.springframework.core.log back to summary

private final Class LogMessage.SupplierMessage

extends LogMessage
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Supplier<? extends CharSequence>

Constructor Summary

AccessConstructor and Description
pack-priv
SupplierMessage(Supplier<? extends CharSequence> supplier)

Method Summary

Modifier and TypeMethod and Description
pack-priv String
Inherited from org.springframework.core.log.LogMessage:
charAtformatformatformatformatformatlengthofsubSequencetoString

Field Detail

supplierback to summary
private final Supplier<? extends CharSequence> supplier

Constructor Detail

SupplierMessageback to summary
pack-priv SupplierMessage(Supplier<? extends CharSequence> supplier)

Method Detail

buildStringback to summary
pack-priv String buildString()

Implements abstract org.springframework.core.log.LogMessage.buildString.

Annotations
@Override