Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ public Boolean getAutoPopulateMetadata() {
* the Json format that can be parsed by the logging agent. If set to {@code false}, logs will be
* ingested to Cloud Logging by calling Logging API.
*
* <p>This method is mutually exclusive with {@link #setLogTarget()}.
* <p>This method is mutually exclusive with {@link #setLogTarget(LogTarget)}.
*
* @deprecated Use {@link #setLogTarget()}.
* @deprecated Use {@link #setLogTarget(LogTarget)}.
*/
@Deprecated
public void setRedirectToStdout(boolean value) {
Expand All @@ -475,7 +475,7 @@ public Boolean getRedirectToStdout() {
* to the corresponding stream in the Json format that can be parsed by the logging agent. If set
* to CLOUD_LOGGING, logs will be sent directly to the Google Cloud Logging API.
*
* <p>This method is mutually exclusive with {@link #setRedirectToStdout()}.
* <p>This method is mutually exclusive with {@link #setRedirectToStdout(boolean)}.
*/
public void setLogTarget(LogTarget value) {
this.logTarget = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.gson.JsonParser;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.logging.ErrorManager;
import java.util.logging.Filter;
import java.util.logging.Formatter;
Expand Down Expand Up @@ -398,14 +399,15 @@ public void testEnhancedLogEntry() {
handler.publish(newLogRecord(Level.FINEST, MESSAGE));
}

void validateJsonOutput(ByteArrayOutputStream bout) {
void validateJsonOutput(ByteArrayOutputStream bout) throws UnsupportedEncodingException {
final String expectedOutput =
"{\"severity\":\"INFO\",\"time\":\"1970-01-02T10:17:36.789Z\",\"logging.googleapis.com/labels\":{\"enhanced\":\"true\"},\"logging.googleapis.com/trace_sampled\":false,\"message\":\"message\"}";
assertEquals(JsonParser.parseString(expectedOutput), JsonParser.parseString(bout.toString()));
assertEquals(
JsonParser.parseString(expectedOutput), JsonParser.parseString(bout.toString("UTF-8")));
}

@Test
public void testEnhancedLogEntryPrintToStdout() {
public void testEnhancedLogEntryPrintToStdout() throws UnsupportedEncodingException {
outputStreamPatcher.patch();

replay(options, logging);
Expand All @@ -422,7 +424,7 @@ public void testEnhancedLogEntryPrintToStdout() {
}

@Test
public void testEnhancedLogEntryPrintToStderr() {
public void testEnhancedLogEntryPrintToStderr() throws UnsupportedEncodingException {
outputStreamPatcher.patch();

replay(options, logging);
Expand Down