Package org.moera.lib.util
Class LogUtil
java.lang.Object
org.moera.lib.util.LogUtil
Utility class for formatting various data types into string representations.
This class is designed to provide consistent formatting for logging purposes,
ensuring proper representation and escaping of values.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
format
(byte[] value) Formats a byte array into a human-readable string representation.static String
Formats aBoolean
value into its string representation.static String
Formats anInteger
value into its string representation.static String
Formats aLong
value into its string representation.static String
Formats a given string value for logging purposes by escaping certain characters and surrounding the value in single quotes.static String
Formats a given string value for logging purposes by truncating it to a maximum length, escaping certain characters, and appending ellipsis if the truncation occurs.static String
Formats aTimestamp
value into its ISO 8601 string representation.static String
Formats aUUID
value into its string representation enclosed in single quotes.static String
Formats aBody
object for logging purposes by encoding its content and truncating it to a specified maximum length.static String
formatTimestamp
(Long value) Formats aLong
value representing a timestamp into its ISO 8601 string representation.
-
Constructor Details
-
LogUtil
public LogUtil()
-
-
Method Details
-
format
Formats a given string value for logging purposes by escaping certain characters and surrounding the value in single quotes. If the value isnull
, the string"null"
is returned.- Parameters:
value
- the string value to be formatted; may benull
- Returns:
- the formatted string, or
"null"
if the input isnull
-
format
Formats anInteger
value into its string representation. If the value isnull
, the string"null"
is returned.- Parameters:
value
- theInteger
value to be formatted; may benull
- Returns:
- the string representation of the integer, or
"null"
if the input isnull
-
format
Formats aLong
value into its string representation. If the value isnull
, the string"null"
is returned.- Parameters:
value
- theLong
value to be formatted; may benull
- Returns:
- the string representation of the long value, or
"null"
if the input isnull
-
format
Formats aBoolean
value into its string representation. If the value isnull
, the string"null"
is returned.- Parameters:
value
- theBoolean
value to be formatted; may benull
- Returns:
- the string representation of the boolean value, or
"null"
if the input isnull
-
format
Formats a given string value for logging purposes by truncating it to a maximum length, escaping certain characters, and appending ellipsis if the truncation occurs. If the value isnull
, the string"null"
is returned.- Parameters:
value
- the string value to be formatted; may benull
maxLength
- the maximum allowed length for the formatted string- Returns:
- the formatted string
-
format
Formats aBody
object for logging purposes by encoding its content and truncating it to a specified maximum length. If theBody
isnull
, the string"null"
is returned.- Parameters:
value
- theBody
object to be formatted; may benull
maxLength
- the maximum allowed length for the formatted string- Returns:
- the formatted string, or
"null"
if the input isnull
-
format
Formats aUUID
value into its string representation enclosed in single quotes. If the value isnull
, the string"null"
is returned.- Parameters:
value
- theUUID
value to be formatted; may benull
- Returns:
- the formatted string, or
"null"
if the input isnull
-
format
Formats a byte array into a human-readable string representation. If the byte array isnull
, the string"null"
is returned. The formatting is handled by theUtil.dumpShort(byte[])
method.- Parameters:
value
- the byte array to format; may benull
- Returns:
- the formatted string representation of the byte array, or
"null"
if the input isnull
-
format
Formats aTimestamp
value into its ISO 8601 string representation. If the value isnull
, the string"null"
is returned.- Parameters:
value
- theTimestamp
value to be formatted; may benull
- Returns:
- the formatted string representation of the timestamp, or
"null"
if the input isnull
-
formatTimestamp
Formats aLong
value representing a timestamp into its ISO 8601 string representation. If the value isnull
, the string"null"
is returned.- Parameters:
value
- theLong
value representing the timestamp to be formatted; may benull
- Returns:
- the formatted string representation of the timestamp, or
"null"
if the input isnull
-