-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Disable logging (stdout, stderr) by default
Bug: b/369223425 Change-Id: Ibe9d20c06dc4bb20409551ce83b0b638c518a915 GitOrigin-RevId: 79a661d6c545149b52cfcd3c646e1503877f52f3
- Loading branch information
1 parent
99e1450
commit 74db753
Showing
4 changed files
with
102 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// 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. | ||
|
||
#include <iostream> | ||
|
||
#include "google/protobuf/any.pb.h" | ||
#include "google/protobuf/util/delimited_message_util.h" | ||
#include "src/roma/byob/udf/sample.pb.h" | ||
|
||
using ::google::protobuf::io::FileInputStream; | ||
using ::google::protobuf::util::ParseDelimitedFromZeroCopyStream; | ||
using ::google::protobuf::util::SerializeDelimitedToFileDescriptor; | ||
using ::privacy_sandbox::server_common::byob::SampleResponse; | ||
|
||
void ReadRequestFromFd(int fd) { | ||
google::protobuf::Any bin_request; | ||
FileInputStream input(fd); | ||
ParseDelimitedFromZeroCopyStream(&bin_request, &input, nullptr); | ||
} | ||
|
||
void WriteResponseToFd(int fd, SampleResponse resp) { | ||
google::protobuf::Any any; | ||
any.PackFrom(std::move(resp)); | ||
google::protobuf::util::SerializeDelimitedToFileDescriptor(any, fd); | ||
} | ||
|
||
int main(int argc, char* argv[]) { | ||
std::cout << "I am a stdout log." << std::endl; | ||
std::cerr << "I am a stderr log." << std::endl; | ||
if (argc < 2) { | ||
std::cerr << "Not enough arguments!" << std::endl; | ||
return -1; | ||
} | ||
int fd = std::stoi(argv[1]); | ||
ReadRequestFromFd(fd); | ||
SampleResponse bin_response; | ||
bin_response.set_greeting("I am a UDF that logs."); | ||
WriteResponseToFd(fd, std::move(bin_response)); | ||
return 0; | ||
} |