Move out logger options from the runtime

#I4SIRR [ https://gitee.com/openharmony/ark_js_runtime/issues/I4SIRR ]
    To be able to use logger options in targets, that don't comprise runtime
    library.
    Add separate target for logger options within libpandabase.
    Hereby, we can use logger options in applications that don't link runtime.
    all test262 testcase

Signed-off-by: Mikhail Sherstennikov <sherstennikov.mikhail@huawei.com>
This commit is contained in:
Mikhail Sherstennikov
2022-01-27 17:08:21 +03:00
parent 206184bc80
commit b8a03be36a
16 changed files with 160 additions and 33 deletions
+1
View File
@@ -53,6 +53,7 @@ group("arkruntime_header_deps") {
":isa_gen_libarkruntime_unimplemented_handlers-inl_h",
":libarkruntime_options_gen_h",
":libarkruntime_shorty_values_h",
"$ark_root/libpandabase:base_options_h",
"$ark_root/verification/gen:isa_gen_verification_gen_abs_int_inl_gen_h",
"$ark_root/verification/gen:isa_gen_verification_gen_cflow_iterate_inl_gen_h",
"$ark_root/verification/gen:isa_gen_verification_gen_job_fill_gen_h",
+2
View File
@@ -306,6 +306,8 @@ panda_gen_options(
GENERATED_HEADER runtime_options_gen.h
)
add_dependencies(arkruntime_static_options arkbase_options)
panda_add_to_clang_tidy(TARGET arkruntime_static)
add_subdirectory(asm_defines)
-2
View File
@@ -81,8 +81,6 @@ public:
LanguageContext GetLanguageContext(panda_file::ClassDataAccessor *cda);
LanguageContext GetLanguageContext(panda_file::SourceLang lang);
static void InitializeLogger(const RuntimeOptions &options);
static bool CreateInstance(const RuntimeOptions &options, mem::InternalAllocatorPtr internal_allocator,
const std::vector<LanguageContextBase *> &ctxs);
+8 -4
View File
@@ -131,8 +131,9 @@ options:
- events
- ecmascript
- scheduler
description: Enable logs from specified components
description: '[DEPRECATED] Option was moved to libpandabase/options.yaml, use base_options::Options instead of runtime options.'
delimiter: ":"
deprecated: true
- name: reference-dump
type: uint64_t
@@ -271,7 +272,8 @@ options:
- info
- error
- fatal
description: Log level
description: '[DEPRECATED] Option was moved to libpandabase/options.yaml, use base_options::Options instead of runtime options.'
deprecated: true
- name: log-stream
type: std::string
@@ -280,12 +282,14 @@ options:
- std
- file
- dummy
description: Log level
description: '[DEPRECATED] Option was moved to libpandabase/options.yaml, use base_options::Options instead of runtime options.'
deprecated: true
- name: log-file
type: std::string
default: ""
description: File name for file-logger
description: '[DEPRECATED] Option was moved to libpandabase/options.yaml, use base_options::Options instead of runtime options.'
deprecated: true
- name: gc-enable-tracing
+3 -24
View File
@@ -196,26 +196,6 @@ LanguageContext Runtime::GetLanguageContext(const std::string &runtime_type)
UNREACHABLE();
}
/* static */
void Runtime::InitializeLogger(const RuntimeOptions &options)
{
panda::Logger::ComponentMask component_mask;
for (const auto &s : options.GetLogComponents()) {
component_mask |= Logger::ComponentMaskFromString(s);
}
if (options.GetLogStream() == "std") {
Logger::InitializeStdLogging(Logger::LevelFromString(options.GetLogLevel()), component_mask);
} else if (options.GetLogStream() == "file") {
const std::string &file_name = options.GetLogFile();
Logger::InitializeFileLogging(file_name, Logger::LevelFromString(options.GetLogLevel()), component_mask);
} else if (options.GetLogStream() == "dummy") {
Logger::InitializeDummyLogging(Logger::LevelFromString(options.GetLogLevel()), component_mask);
} else {
UNREACHABLE();
}
}
/* static */
bool Runtime::CreateInstance(const RuntimeOptions &options, mem::InternalAllocatorPtr internal_allocator,
const std::vector<LanguageContextBase *> &ctxs)
@@ -262,8 +242,6 @@ bool Runtime::Create(const RuntimeOptions &options, const std::vector<LanguageCo
CreateDfxController(options);
InitializeLogger(options);
CreateInstance(options, internal_allocator, ctxs);
if (!instance->Initialize()) {
@@ -485,8 +463,9 @@ Runtime::~Runtime()
bool Runtime::IsEnableMemoryHooks() const
{
auto log_level = options_.GetLogLevel();
return options_.IsLimitStandardAlloc() && (log_level == "fatal" || log_level == "error") &&
auto log_level = Logger::IsInitialized() ? Logger::GetLevel() : Logger::Level::DEBUG;
return options_.IsLimitStandardAlloc() &&
(log_level == Logger::Level::FATAL || log_level == Logger::Level::ERROR) &&
(!options_.UseMallocForInternalAllocations());
}
-1
View File
@@ -66,7 +66,6 @@ void RuntimeOptionsTest::LoadCorrectOptionsList()
AddTestingOption("sigquit-flag", "1234");
AddTestingOption("dfx-log", "1234");
AddTestingOption("gc-dump-heap", "true");
AddTestingOption("log-file", "string");
AddTestingOption("start-as-zygote", "true");
AddTestingOption("verification-enabled", "true");
AddTestingOption("pre-gc-heap-verify-enabled", "true");