Class LoggingInterceptor

java.lang.Object
java.util.logging.Handler
com.google.cloud.hadoop.util.interceptors.LoggingInterceptor

public class LoggingInterceptor extends Handler
A logging interceptor that publishes log records to Google Cloud Logging. This class extends Handler to integrate with the Java logging framework.
  • Constructor Details

    • LoggingInterceptor

      public LoggingInterceptor(com.google.auth.oauth2.GoogleCredentials credentials, String logNameSuffix)
      Constructs a new LoggingInterceptor.
      Parameters:
      credentials - the Google Cloud credentials used to authenticate with the Logging service
      logNameSuffix - the suffix to append to the log name
  • Method Details

    • createLoggingService

      protected com.google.cloud.logging.Logging createLoggingService(com.google.auth.oauth2.GoogleCredentials credentials)
      Creates a Google Cloud Logging service instance.
      Parameters:
      credentials - the Google Cloud credentials used to authenticate with the Logging service
      Returns:
      a Logging instance
    • publish

      public void publish(LogRecord record)
      Publishes a log record to Google Cloud Logging.
      Specified by:
      publish in class Handler
      Parameters:
      record - the log record to publish
    • flush

      public void flush()
      Flushes any buffered log entries to Google Cloud Logging.
      Specified by:
      flush in class Handler
    • close

      public void close() throws SecurityException
      Closes the Google Cloud Logging service.
      Specified by:
      close in class Handler
      Throws:
      SecurityException - if an error occurs while closing the service