원클릭으로
gflog
// Add or update logging statements using GFLog library. Use when creating new log statements, refactoring existing logging code (JUL/SLF4J), or when you see string concatenation in log statements.
// Add or update logging statements using GFLog library. Use when creating new log statements, refactoring existing logging code (JUL/SLF4J), or when you see string concatenation in log statements.
| name | gflog |
| description | Add or update logging statements using GFLog library. Use when creating new log statements, refactoring existing logging code (JUL/SLF4J), or when you see string concatenation in log statements. |
Add logging statements using our company standard GFLog library.
When you see string concatenation in existing log statement you need to replace it with printf-like approach followed by GFLog.
For example:
LOGGER.log(Level.FINE, "Found " + list.size() + " instruments");
should be
LOG.debug("Found %s instruments").with(list.size());
Timestamps (epoch millis as long):
.withTimestamp(value).withTimestamp(System.currentTimeMillis())DFP-encoded money/quantities (long representing Decimal64):
.withDecimal64(value).withDecimal64(price) for prices, .withDecimal64(quantity) for quantitiesAlphanumeric identifiers (@Alphanumeric long):
.withAlphanumeric(value).withAlphanumeric(instrumentId) for encoded symbol/IDRegular values:
.with(value)Initialize logger (at class level):
protected static final Log LOG = LogFactory.getLog(CurrentClass.class);
Basic logging:
LOG.info("Hello %s! Current time is %s")
.with(name)
.withTimestamp(System.currentTimeMillis());
With guard for expensive operations:
if (LOG.isDebugEnabled()) {
LOG.debug("Computed result: %s").with(expensiveComputation());
}
Here we need to make sure that function expensiveComputation() does not perform any logging of its own inside its body.
GFLog is not re-entrant. In such cases it is better to move function call outside of logging statement:
if (LOG.isDebugEnabled()) {
var x = expensiveComputation();
LOG.debug("Computed result: %s").with(x);
}
Only %s is supported as a format specifier — type-specific specifiers (%d, %04d, %f, etc.) are not recognized.
LOG.info("Value is %04d").with(value)LOG.info("Value is %s").with(value)Every .with*() call must have a matching %s placeholder in the format string.
LOG.error("Error").with(exception)LOG.error("Error: %s").with(exception)Use typed appenders instead of .with() for timestamps and DFP values:
.withTimestamp(value), epoch nanos → .withTimestampNs(value)Decimal64-encoded long → .withDecimal64(value)LOG.info("Message time is %s").with(message.getTimestamp())LOG.info("Message time is %s").withTimestamp(message.getTimestamp())