Class LoggingInterceptor
java.lang.Object
java.util.logging.Handler
com.google.cloud.hadoop.util.interceptors.LoggingInterceptor
A logging interceptor that publishes log records to Google Cloud Logging. This class extends
Handler to integrate with the Java logging framework.-
Constructor Summary
ConstructorsConstructorDescriptionLoggingInterceptor(com.google.auth.oauth2.GoogleCredentials credentials, String logNameSuffix) Constructs a newLoggingInterceptor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the Google Cloud Logging service.protected com.google.cloud.logging.LoggingcreateLoggingService(com.google.auth.oauth2.GoogleCredentials credentials) Creates a Google Cloud Logging service instance.voidflush()Flushes any buffered log entries to Google Cloud Logging.voidPublishes a log record to Google Cloud Logging.Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
Constructor Details
-
LoggingInterceptor
public LoggingInterceptor(com.google.auth.oauth2.GoogleCredentials credentials, String logNameSuffix) Constructs a newLoggingInterceptor.- Parameters:
credentials- the Google Cloud credentials used to authenticate with the Logging servicelogNameSuffix- 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
Logginginstance
-
publish
Publishes a log record to Google Cloud Logging. -
flush
public void flush()Flushes any buffered log entries to Google Cloud Logging. -
close
Closes the Google Cloud Logging service.- Specified by:
closein classHandler- Throws:
SecurityException- if an error occurs while closing the service
-