3.39.0

(feat): Add support for logging to the generated SDK. Users can configure logging by passing a LogConfig to the client builder’s .logging() method.

1import com.example.api.AcmeApiClient;
2import com.example.api.core.LogConfig;
3import com.example.api.core.LogLevel;
4import com.example.api.core.ConsoleLogger;
5
6AcmeApiClient client = AcmeApiClient.builder()
7 .token("YOUR_TOKEN")
8 .logging(LogConfig.builder()
9 .level(LogLevel.DEBUG) // INFO is the default
10 .logger(new ConsoleLogger()) // ConsoleLogger is the default
11 .silent(false) // true is the default, set to false to enable logging
12 .build())
13 .build();

The LogConfig builder accepts the following properties:

  • level(LogLevel): The log level to use. Defaults to LogLevel.INFO.
  • logger(ILogger): The logger implementation to use. Defaults to ConsoleLogger.
  • silent(boolean): Whether to silence the logger. Defaults to true.

The LogLevel enum supports the following values:

  • DEBUG
  • INFO
  • WARN
  • ERROR

To provide a custom logger, implement the ILogger interface with debug, info, warn, and error methods.

HTTP request and response details (method, URL, status code, headers, body) are logged via a LoggingInterceptor added to the OkHttp client. Sensitive headers (authorization, x-api-key, cookie, x-csrf-token, etc.) are automatically redacted in logs.