Make mobile log per-host and rename as context

pull/15567/head
Muxi Yan 7 years ago
parent 5d83bedb77
commit 4dbd18aec5
  1. 2
      include/grpc/impl/codegen/grpc_types.h
  2. 30
      src/objective-c/GRPCClient/GRPCCall+MobileLog.h
  3. 33
      src/objective-c/GRPCClient/GRPCCall+MobileLog.m
  4. 1
      src/objective-c/GRPCClient/private/GRPCHost.h
  5. 7
      src/objective-c/GRPCClient/private/GRPCHost.m

@ -332,7 +332,7 @@ typedef struct {
#define GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE "grpc.per_rpc_retry_buffer_size" #define GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE "grpc.per_rpc_retry_buffer_size"
/** Channel arg that carries the bridged objective c object for custom metrics /** Channel arg that carries the bridged objective c object for custom metrics
* logging filter. */ * logging filter. */
#define GRPC_ARG_MOBILE_LOG_CONFIG "grpc.mobile_log_config" #define GRPC_ARG_MOBILE_LOG_CONTEXT "grpc.mobile_log_context"
/** If non-zero, client authority filter is disabled for the channel */ /** If non-zero, client authority filter is disabled for the channel */
#define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \ #define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \
"grpc.disable_client_authority_filter" "grpc.disable_client_authority_filter"

@ -1,30 +0,0 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#import "GRPCCall.h"
@interface GRPCCall (MobileLog)
// Set the object to be passed down along channel stack with channel arg
// GRPC_ARG_MOBILE_LOG_CONFIG. The setting may be used by custom channel
// filters for metrics logging.
+ (void)setLogConfig:(id)logConfig;
// Obtain the object to be passed down along channel stack with channel arg
// GRPC_ARG_MOBILE_LOG_CONFIG.
+ (id)logConfig;
@end

@ -1,33 +0,0 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#import "GRPCCall+MobileLog.h"
static id globalLogConfig = nil;
@implementation GRPCCall (MobileLog)
+ (void)setLogConfig:(id)logConfig {
globalLogConfig = logConfig;
}
+ (id)logConfig {
return globalLogConfig;
}
@end

@ -37,6 +37,7 @@ struct grpc_channel_credentials;
@property(nonatomic) grpc_compression_algorithm compressAlgorithm; @property(nonatomic) grpc_compression_algorithm compressAlgorithm;
@property(nonatomic) int keepaliveInterval; @property(nonatomic) int keepaliveInterval;
@property(nonatomic) int keepaliveTimeout; @property(nonatomic) int keepaliveTimeout;
@property(nonatomic) id logContext;
/** The following properties should only be modified for testing: */ /** The following properties should only be modified for testing: */

@ -18,7 +18,6 @@
#import "GRPCHost.h" #import "GRPCHost.h"
#import <GRPCClient/GRPCCall+MobileLog.h>
#import <GRPCClient/GRPCCall.h> #import <GRPCClient/GRPCCall.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
@ -223,9 +222,9 @@ static NSMutableDictionary *kHostCache;
args[@GRPC_ARG_KEEPALIVE_TIMEOUT_MS] = [NSNumber numberWithInt:_keepaliveTimeout]; args[@GRPC_ARG_KEEPALIVE_TIMEOUT_MS] = [NSNumber numberWithInt:_keepaliveTimeout];
} }
id logConfig = [GRPCCall logConfig]; id logContext = self.logContext;
if (logConfig != nil) { if (logContext != nil) {
args[@GRPC_ARG_MOBILE_LOG_CONFIG] = logConfig; args[@GRPC_ARG_MOBILE_LOG_CONTEXT] = logContext;
} }
if (useCronet) { if (useCronet) {

Loading…
Cancel
Save