use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.
the class Debug method debugException.
/**
* Writes debug information about the provided exception, if appropriate.
*
* @param l The log level that should be used for the debug information.
* @param t The exception for which debug information should be written.
*/
public static void debugException(@NotNull final Level l, @NotNull final Throwable t) {
if (debugEnabled && debugTypes.contains(DebugType.EXCEPTION)) {
final JSONBuffer buffer = new JSONBuffer();
addCommonHeader(buffer, l, DebugType.EXCEPTION);
addCaughtException(buffer, "caught-exception", t);
addCommonFooter(buffer);
log(l, buffer, t);
}
}
use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.
the class Debug method debugConnectionPool.
/**
* Writes debug information about interaction with a connection pool.
*
* @param l The log level that should be used for the debug information.
* @param p The associated connection pool.
* @param c The associated LDAP connection, if appropriate.
* @param m A message with information about the pool interaction.
* @param e An exception to include with the log message, if appropriate.
*/
public static void debugConnectionPool(@NotNull final Level l, @NotNull final AbstractConnectionPool p, @Nullable final LDAPConnection c, @Nullable final String m, @Nullable final Throwable e) {
if (debugEnabled && debugTypes.contains(DebugType.CONNECTION_POOL)) {
final JSONBuffer buffer = new JSONBuffer();
addCommonHeader(buffer, l, DebugType.CONNECTION_POOL);
final String poolName = p.getConnectionPoolName();
if (poolName == null) {
buffer.appendNull("connection-pool-name");
} else {
buffer.appendString("connection-pool-name", poolName);
}
if (c != null) {
buffer.appendNumber("connection-id", c.getConnectionID());
final String connectedAddress = c.getConnectedAddress();
if (connectedAddress != null) {
buffer.appendString("connected-to-address", connectedAddress);
buffer.appendNumber("connected-to-port", c.getConnectedPort());
}
}
final long currentAvailable = p.getCurrentAvailableConnections();
if (currentAvailable >= 0) {
buffer.appendNumber("current-available-connections", currentAvailable);
}
final long maxAvailable = p.getMaximumAvailableConnections();
if (maxAvailable >= 0) {
buffer.appendNumber("maximum-available-connections", maxAvailable);
}
if (m != null) {
buffer.appendString("message", m);
}
if (e != null) {
addCaughtException(buffer, "caught-exception", e);
}
addCommonFooter(buffer);
log(l, buffer, e);
}
}
use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.
the class Debug method debugMonitor.
/**
* Writes debug information about monitor entry parsing, if appropriate.
*
* @param l The log level that should be used for the debug information.
* @param e The entry containing the monitor information being parsed.
* @param m The message to be written to the debug logger.
*/
public static void debugMonitor(@NotNull final Level l, @Nullable final Entry e, @Nullable final String m) {
if (debugEnabled && debugTypes.contains(DebugType.MONITOR)) {
final JSONBuffer buffer = new JSONBuffer();
addCommonHeader(buffer, l, DebugType.MONITOR);
if (e != null) {
buffer.appendString("monitor-entry-dn", e.getDN());
}
if (m != null) {
buffer.appendString("message", m);
}
addCommonFooter(buffer);
log(l, buffer);
}
}
use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.
the class JSONAccessLogRequestHandler method getConnectionHeader.
/**
* Retrieves a {@code JSONBuffer} with header information for a connect log
* message for the specified type of operation.
*
* @param messageType The type of operation being requested.
*
* @return A {@code JSONBuffer} with header information appended for the
* connection;
*/
@NotNull()
private JSONBuffer getConnectionHeader(@NotNull final String messageType) {
final JSONBuffer buffer = getBuffer();
buffer.beginObject();
addTimestamp(buffer);
buffer.appendString("message-type", messageType);
buffer.appendNumber("connection-id", clientConnection.getConnectionID());
return buffer;
}
use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.
the class JSONAccessLogRequestHandler method getBuffer.
/**
* Retrieves a JSON buffer that can be used to construct a log message.
*
* @return A JSON buffer that can be used to construct a log message.
*/
@NotNull()
private JSONBuffer getBuffer() {
JSONBuffer buffer = jsonBuffers.get();
if (buffer == null) {
buffer = new JSONBuffer();
jsonBuffers.set(buffer);
} else {
buffer.clear();
}
return buffer;
}
Aggregations