From f10676c2b4ac6fa614000fbc306c25c6fabc25c9 Mon Sep 17 00:00:00 2001 From: zpencer Date: Mon, 8 Oct 2018 15:44:18 -0700 Subject: [PATCH] services: allow config str to be passed into binlog object (#4919) Do not require binlog str to be defined by env var. This allows --flag=value styled configuration, which is more common internally. --- .../io/grpc/services/BinaryLogProviderImpl.java | 6 +++++- .../src/main/java/io/grpc/services/BinaryLogs.java | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/services/src/main/java/io/grpc/services/BinaryLogProviderImpl.java b/services/src/main/java/io/grpc/services/BinaryLogProviderImpl.java index 39fee44d35..dee13a924c 100644 --- a/services/src/main/java/io/grpc/services/BinaryLogProviderImpl.java +++ b/services/src/main/java/io/grpc/services/BinaryLogProviderImpl.java @@ -38,6 +38,10 @@ class BinaryLogProviderImpl extends BinaryLogProvider { this(new TempFileSink(), System.getenv("GRPC_BINARY_LOG_CONFIG")); } + /** + * Deprecated and will be removed in a future version of gRPC. + */ + @Deprecated public BinaryLogProviderImpl(BinaryLogSink sink) throws IOException { this(sink, System.getenv("GRPC_BINARY_LOG_CONFIG")); } @@ -48,7 +52,7 @@ class BinaryLogProviderImpl extends BinaryLogProvider { * @param configStr config string to parse to determine logged methods and msg size limits. * @throws IOException if initialization failed. */ - BinaryLogProviderImpl(BinaryLogSink sink, String configStr) throws IOException { + public BinaryLogProviderImpl(BinaryLogSink sink, String configStr) throws IOException { this.sink = Preconditions.checkNotNull(sink); try { factory = new BinlogHelper.FactoryImpl(sink, configStr); diff --git a/services/src/main/java/io/grpc/services/BinaryLogs.java b/services/src/main/java/io/grpc/services/BinaryLogs.java index de7f79116f..fc2d8d84ad 100644 --- a/services/src/main/java/io/grpc/services/BinaryLogs.java +++ b/services/src/main/java/io/grpc/services/BinaryLogs.java @@ -32,11 +32,22 @@ public final class BinaryLogs { } /** - * Creates a binary log with a custom {@link BinaryLogSink} for receiving the logged data. + * Deprecated and will be removed in a future version of gRPC. */ + @Deprecated public static BinaryLog createBinaryLog(BinaryLogSink sink) throws IOException { return new BinaryLogProviderImpl(sink); } + /** + * Creates a binary log with a custom {@link BinaryLogSink} for receiving the logged data, + * and a config string as defined by + * + * A16-binary-logging. + */ + public static BinaryLog createBinaryLog(BinaryLogSink sink, String configStr) throws IOException { + return new BinaryLogProviderImpl(sink, configStr); + } + private BinaryLogs() {} }