public final class LogHelper extends Object
logId(String, String)
for N and userName, so subsequent log messages can use
logId(String)
for N only and show both the ID and the name.
// Create user. ID and user name both known at this point. LOG.info("User created: {}", logId(id, name)); ... // Finds user ID only. User name not known here, but inserted by log helper. LOG.info("Found user: {}", logId(id));Note that the LogHelper class has a limited cache of (key, value) pairs, to limit memory usage. The cache auto-expires unused items as well.
Modifier and Type | Method and Description |
---|---|
static void |
enable(boolean enable)
Enable or disable the cache.
|
static boolean |
isEnabled()
Return whether the LogHelper is enabled or not.
|
static String |
logId(String key)
Get a value from the map.
|
static String |
logId(String key,
String value)
Store a value from the key/value store and return the key with the value appended.
|
static String |
logId(Uid<?> key)
Get a value from the map.
|
static String |
logId(Uid<?> key,
String value)
Store a value from the key/value store and return the key with the value appended.
|
static String |
logIdName(String key)
Get a name from the map.
|
static String |
logIdName(Uid<?> key)
Get only the name from the map.
|
public static void enable(boolean enable)
enable
- True to enable.public static boolean isEnabled()
@Nullable public static String logId(@Nullable Uid<?> key, @Nullable String value)
key
- Unique key.value
- Value. If null, the key/value pair is effectively removed from the map.@Nullable public static String logId(@Nullable Uid<?> key)
key
- Unique key.@Nullable public static String logId(@Nullable String key, @Nullable String value)
key
- Unique key.value
- Value. If null, the key/value pair is effectively removed from the map.@Nullable public static String logId(@Nullable String key)
key
- Unique key.@Nonnull public static String logIdName(@Nullable Uid<?> key)
key
- Unique key.Copyright © 2018 TomTom International BV. All rights reserved.