From deb770caba0c3c99b19ffe9b57872923d2541c51 Mon Sep 17 00:00:00 2001 From: Jan Christoph Uhde Date: Tue, 26 Mar 2019 09:19:16 +0100 Subject: [PATCH] fix generateLogIds.py (#8570) * fix generateLogIds.py, update README_mainatiners * Add missing `or` in doc. * remove quotes before inserting into map --- README_maintainers.md | 6 +++--- lib/V8/v8-utils.cpp | 19 +++++++++++-------- utils/generateLogIds.py | 6 ++++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/README_maintainers.md b/README_maintainers.md index b211d6800a..a2f1b56c58 100644 --- a/README_maintainers.md +++ b/README_maintainers.md @@ -20,12 +20,12 @@ Unique Log Ids We have unique log ids in order to allow for easy locating of code producing errors. - LOG_TOPIC(2dead, ....) + LOG_TOPIC("2dead", ....) To ensure that the ids are unique we run the script `./utils/generateLogIds.py` during CI runs. The script will fail with a non-zero status if id collisions -are found. You can use `openssl rand -hex 3 | sed 's/.//'` anything that suits -you to generate a **5 hex digit log** id. +are found. You can use `openssl rand -hex 3 | sed 's/.//;s/\(.*\)/"\1"/'` or +anything that suits you to generate a **5 hex digit log** id. CMake ===== diff --git a/lib/V8/v8-utils.cpp b/lib/V8/v8-utils.cpp index 07a8af4279..291dd875d0 100644 --- a/lib/V8/v8-utils.cpp +++ b/lib/V8/v8-utils.cpp @@ -1875,8 +1875,8 @@ static void JS_Log(v8::FunctionCallbackInfo const& args) { StringUtils::tolowerInPlace(&ls); StringUtils::tolowerInPlace(&ts); - LogTopic const* topicPtr = LogTopic::lookup(ts); - LogTopic const& topic = ( ts.empty() || topicPtr == nullptr ) ? Logger::FIXME : *topicPtr; + LogTopic const* topicPtr = ts.empty() ? nullptr : LogTopic::lookup(ts); + LogTopic const& topic = (topicPtr != nullptr) ? *topicPtr : Logger::FIXME; if (args[1]->IsArray()) { auto loglines = v8::Handle::Cast(args[1]); @@ -1910,7 +1910,7 @@ static void JS_Log(v8::FunctionCallbackInfo const& args) { prefix = ls + "!"; LOG_TOPIC("6b817", WARN, topic) << prefix << message; } - } // for + } // for } else { TRI_Utf8ValueNFC message(isolate, args[1]); @@ -1937,7 +1937,6 @@ static void JS_Log(v8::FunctionCallbackInfo const& args) { prefix = ls + "!"; LOG_TOPIC("0c009", WARN, topic) << prefix << msg; } - } TRI_V8_RETURN_UNDEFINED(); @@ -4367,9 +4366,11 @@ void TRI_LogV8Exception(v8::Isolate* isolate, v8::TryCatch* tryCatch) { // exception. if (message.IsEmpty()) { if (exceptionString == nullptr) { - LOG_TOPIC("49465", ERR, arangodb::Logger::FIXME) << "JavaScript exception"; + LOG_TOPIC("49465", ERR, arangodb::Logger::FIXME) + << "JavaScript exception"; } else { - LOG_TOPIC("7e60e", ERR, arangodb::Logger::FIXME) << "JavaScript exception: " << exceptionString; + LOG_TOPIC("7e60e", ERR, arangodb::Logger::FIXME) + << "JavaScript exception: " << exceptionString; } } else { TRI_Utf8ValueNFC filename(isolate, message->GetScriptResourceName()); @@ -4382,9 +4383,11 @@ void TRI_LogV8Exception(v8::Isolate* isolate, v8::TryCatch* tryCatch) { if (filenameString == nullptr) { if (exceptionString == nullptr) { - LOG_TOPIC("27c91", ERR, arangodb::Logger::FIXME) << "JavaScript exception"; + LOG_TOPIC("27c91", ERR, arangodb::Logger::FIXME) + << "JavaScript exception"; } else { - LOG_TOPIC("52220", ERR, arangodb::Logger::FIXME) << "JavaScript exception: " << exceptionString; + LOG_TOPIC("52220", ERR, arangodb::Logger::FIXME) + << "JavaScript exception: " << exceptionString; } } else { if (exceptionString == nullptr) { diff --git a/utils/generateLogIds.py b/utils/generateLogIds.py index 4009f72c28..39ae106f85 100755 --- a/utils/generateLogIds.py +++ b/utils/generateLogIds.py @@ -25,6 +25,8 @@ g_hash_algorithm = hashlib.md5() def generate_id(location_string, params, rest, id_database): + sys.exit(1) #disabled on purpose + id_len = 5 g_hash_algorithm.update((location_string + params + rest).encode()) digest = g_hash_algorithm.hexdigest() @@ -107,9 +109,9 @@ def do_operation(fullpath, project_path, target_file_handle, id_database, levels # still unmodified continue - elif len(param) == 5: + elif len(param) == 7 and param.startswith('"') and param.endswith('"'): # we need to store / check the id - uid = param + uid = param[1:-1] if uid in id_database: print("collision check failed - the following lines contain equal ids:")