Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure logging in the SpeechToText example #973

Merged
merged 1 commit into from
Sep 25, 2020
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
4 changes: 4 additions & 0 deletions Examples/Google/SpeechToText/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Pods
Sources/Generated
google
googleapis
2 changes: 1 addition & 1 deletion Examples/Google/SpeechToText/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ target 'SpeechToText-gRPC-iOS' do
use_frameworks!

pod 'SnapKit'
pod 'gRPC-Swift', '1.0.0-alpha.14'
pod 'gRPC-Swift', '1.0.0-alpha.19'
end
8 changes: 7 additions & 1 deletion Examples/Google/SpeechToText/Sources/SpeechService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import GRPC
import Logging

typealias Request = Google_Cloud_Speech_V1_StreamingRecognizeRequest
typealias Response = Google_Cloud_Speech_V1_StreamingRecognizeResponse
Expand Down Expand Up @@ -43,15 +44,20 @@ final class SpeechService {
// see https://github.com/grpc/grpc-swift/blob/main/docs/apple-platforms.md for more details
let group = PlatformSupport.makeEventLoopGroup(loopCount: 1)

// Setup a logger for debugging.
var logger = Logger(label: "gRPC", factory: StreamLogHandler.standardOutput(label:))
logger.logLevel = .debug

// Create a connection secured with TLS to Google's speech service running on our `EventLoopGroup`
let channel = ClientConnection
.secure(group: group)
.withBackgroundActivityLogger(logger)
.connect(host: "speech.googleapis.com", port: 443)

// Specify call options to be used for gRPC calls
let callOptions = CallOptions(customMetadata: [
"x-goog-api-key": Constants.apiKey,
])
], logger: logger)

// Now we have a client!
self.client = Google_Cloud_Speech_V1_SpeechClient(
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ necessary targets:

```swift
dependencies: [
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.0.0-alpha.12")
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.0.0-alpha.19")
]
```

Expand Down Expand Up @@ -96,7 +96,7 @@ gRPC Swift is currently available [from CocoaPods][pod-new]. To integrate, add
the following line to your `Podfile`:

```ruby
pod 'gRPC-Swift', '~> 1.0.0-alpha.18'
pod 'gRPC-Swift', '~> 1.0.0-alpha.19'
```

Then, run `pod install` from command line and use your project's generated
Expand Down