chore: add ability to log native deprecation warnings (#18681)
* chore: add ability to log native deprecation warnings * take std::string, handle conversion later * address feedback from @ckerr's review * simplify with feedback from zcbenz
This commit is contained in:
parent
a42ed950ca
commit
a0b2810640
3 changed files with 49 additions and 0 deletions
27
atom/common/deprecate_util.cc
Normal file
27
atom/common/deprecate_util.cc
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) 2019 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/common/deprecate_util.h"
|
||||
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "base/callback.h"
|
||||
#include "native_mate/converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
void EmitDeprecationWarning(node::Environment* env,
|
||||
const std::string& warning_msg,
|
||||
const std::string& warning_type) {
|
||||
mate::Dictionary process(env->isolate(), env->process_object());
|
||||
|
||||
base::RepeatingCallback<void(base::StringPiece, base::StringPiece,
|
||||
base::StringPiece)>
|
||||
emit_warning;
|
||||
process.Get("emitWarning", &emit_warning);
|
||||
|
||||
emit_warning.Run(warning_msg, warning_type, "");
|
||||
}
|
||||
|
||||
} // namespace atom
|
20
atom/common/deprecate_util.h
Normal file
20
atom/common/deprecate_util.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) 2019 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_COMMON_DEPRECATE_UTIL_H_
|
||||
#define ATOM_COMMON_DEPRECATE_UTIL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
void EmitDeprecationWarning(node::Environment* env,
|
||||
const std::string& warning_msg,
|
||||
const std::string& warning_type);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_COMMON_DEPRECATE_UTIL_H_
|
|
@ -511,6 +511,8 @@ filenames = {
|
|||
"atom/common/key_weak_map.h",
|
||||
"atom/common/keyboard_util.cc",
|
||||
"atom/common/keyboard_util.h",
|
||||
"atom/common/deprecate_util.cc",
|
||||
"atom/common/deprecate_util.h",
|
||||
"atom/common/mouse_util.cc",
|
||||
"atom/common/mouse_util.h",
|
||||
"atom/common/mac/main_application_bundle.h",
|
||||
|
|
Loading…
Reference in a new issue