Skip to content

Commit

Permalink
log deprecated opertions to scuba
Browse files Browse the repository at this point in the history
Reviewed By: thedavekwon

Differential Revision: D67885587

fbshipit-source-id: aeb1a1d374e81dba97a3d2a3697bd2e1b02b3abc
  • Loading branch information
TJ Yin authored and facebook-github-bot committed Jan 8, 2025
1 parent 9fff2f1 commit 87b947a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <thrift/lib/cpp/util/VarintUtils.h>
#include <thrift/lib/cpp2/Adapter.h>
#include <thrift/lib/cpp2/op/detail/BasePatch.h>
#include <thrift/lib/cpp2/patch/detail/Scuba.h>

namespace apache::thrift::op::detail {

Expand Down Expand Up @@ -127,7 +128,13 @@ class ListPatch : public BaseContainerPatch<Patch, ListPatch<Patch>> {
return;
}

DCHECK(data_.prepend()->empty()) << "Prepend in ListPatch is disallowed.";
if (!data_.prepend()->empty()) {
auto msg = "Prepend in ListPatch is disallowed.";
LOG(DFATAL) << msg;
patch::detail::logDeprecatedOperation(
"ListPatch::Prepend", folly::pretty_name<T>(), msg);
}

v.prepend(*data_.prepend());
v.appendMulti(*data_.append());
}
Expand Down
26 changes: 26 additions & 0 deletions third-party/thrift/src/thrift/lib/cpp2/patch/detail/Scuba.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* 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 <thrift/lib/cpp2/patch/detail/Scuba.h>

namespace apache::thrift::patch::detail {
THRIFT_PLUGGABLE_FUNC_REGISTER(
void,
logDeprecatedOperation,
std::string_view,
std::string_view,
std::string_view) {}
} // namespace apache::thrift::patch::detail
29 changes: 29 additions & 0 deletions third-party/thrift/src/thrift/lib/cpp2/patch/detail/Scuba.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* 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.
*/

#pragma once

#include <string_view>
#include <thrift/lib/cpp2/PluggableFunction.h>

namespace apache::thrift::patch::detail {
THRIFT_PLUGGABLE_FUNC_DECLARE(
void,
logDeprecatedOperation,
std::string_view operation,
std::string_view type,
std::string_view message);
}

0 comments on commit 87b947a

Please sign in to comment.