diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2020-02-13 11:49:46 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-13 18:16:35 +0000 |
commit | a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761 (patch) | |
tree | 85ac46cd5f4ea6d5134560bf764fb9e6cf11fe4e /src/mongo/scripting | |
parent | 6df40e01f7b6899affc4536e7e73a35802cabf98 (diff) | |
download | mongo-a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761.tar.gz |
SERVER-45869 automatically converted structured logging
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r-- | src/mongo/scripting/engine.cpp | 17 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/cursor_handle.cpp | 6 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/engine.cpp | 25 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/implscope.cpp | 15 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/session.cpp | 6 |
5 files changed, 53 insertions, 16 deletions
diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp index 77017f455ae..fb18a034226 100644 --- a/src/mongo/scripting/engine.cpp +++ b/src/mongo/scripting/engine.cpp @@ -40,6 +40,7 @@ #include "mongo/client/dbclient_cursor.h" #include "mongo/db/operation_context.h" #include "mongo/db/service_context.h" +#include "mongo/logv2/log.h" #include "mongo/scripting/dbdirectclient_factory.h" #include "mongo/util/fail_point.h" #include "mongo/util/file.h" @@ -137,7 +138,7 @@ bool Scope::execFile(const string& filename, bool printResult, bool reportError, boost::filesystem::path p(filename); #endif if (!exists(p)) { - error() << "file [" << filename << "] doesn't exist"; + LOGV2_ERROR(22779, "file [{filename}] doesn't exist", "filename"_attr = filename); return false; } @@ -156,7 +157,9 @@ bool Scope::execFile(const string& filename, bool printResult, bool reportError, } if (empty) { - error() << "directory [" << filename << "] doesn't have any *.js files"; + LOGV2_ERROR(22780, + "directory [{filename}] doesn't have any *.js files", + "filename"_attr = filename); return false; } @@ -171,7 +174,7 @@ bool Scope::execFile(const string& filename, bool printResult, bool reportError, fileofs fo = f.len(); if (fo > kMaxJsFileLength) { - warning() << "attempted to execute javascript file larger than 2GB"; + LOGV2_WARNING(22778, "attempted to execute javascript file larger than 2GB"); return false; } unsigned len = static_cast<unsigned>(fo); @@ -258,8 +261,10 @@ void Scope::loadStored(OperationContext* opCtx, bool ignoreNotConnected) { throw; } - error() << "unable to load stored JavaScript function " << n.valuestr() - << "(): " << redact(setElemEx); + LOGV2_ERROR(22781, + "unable to load stored JavaScript function {n_valuestr}(): {setElemEx}", + "n_valuestr"_attr = n.valuestr(), + "setElemEx"_attr = redact(setElemEx)); } } @@ -339,7 +344,7 @@ public: if (scope->hasOutOfMemoryException()) { // make some room - log() << "Clearing all idle JS contexts due to out of memory"; + LOGV2(22777, "Clearing all idle JS contexts due to out of memory"); _pools.clear(); return; } diff --git a/src/mongo/scripting/mozjs/cursor_handle.cpp b/src/mongo/scripting/mozjs/cursor_handle.cpp index 101334a737b..80a1950d46d 100644 --- a/src/mongo/scripting/mozjs/cursor_handle.cpp +++ b/src/mongo/scripting/mozjs/cursor_handle.cpp @@ -32,6 +32,7 @@ #include "mongo/platform/basic.h" #include "mongo/client/dbclient_base.h" +#include "mongo/logv2/log.h" #include "mongo/scripting/mozjs/cursor_handle.h" #include "mongo/scripting/mozjs/implscope.h" #include "mongo/scripting/mozjs/scripting_util_gen.h" @@ -77,7 +78,10 @@ void CursorHandleInfo::finalize(js::FreeOp* fop, JSObject* obj) { auto status = exceptionToStatus(); try { - LOG(0) << "Failed to kill cursor " << cursorId << " due to " << status; + LOGV2(22782, + "Failed to kill cursor {cursorId} due to {status}", + "cursorId"_attr = cursorId, + "status"_attr = status); } catch (...) { // This is here in case logging fails. } diff --git a/src/mongo/scripting/mozjs/engine.cpp b/src/mongo/scripting/mozjs/engine.cpp index 766c2fce637..2b921bf01f7 100644 --- a/src/mongo/scripting/mozjs/engine.cpp +++ b/src/mongo/scripting/mozjs/engine.cpp @@ -36,6 +36,7 @@ #include <js/Initialization.h> #include "mongo/db/operation_context.h" +#include "mongo/logv2/log.h" #include "mongo/scripting/mozjs/engine_gen.h" #include "mongo/scripting/mozjs/implscope.h" #include "mongo/scripting/mozjs/proxyscope.h" @@ -86,11 +87,19 @@ void MozJSScriptEngine::interrupt(unsigned opId) { OpIdToScopeMap::iterator iScope = _opToScopeMap.find(opId); if (iScope == _opToScopeMap.end()) { // got interrupt request for a scope that no longer exists - LOG(1) << "received interrupt request for unknown op: " << opId << printKnownOps_inlock(); + LOGV2_DEBUG(22783, + 1, + "received interrupt request for unknown op: {opId}{printKnownOps_inlock}", + "opId"_attr = opId, + "printKnownOps_inlock"_attr = printKnownOps_inlock()); return; } - LOG(1) << "interrupting op: " << opId << printKnownOps_inlock(); + LOGV2_DEBUG(22784, + 1, + "interrupting op: {opId}{printKnownOps_inlock}", + "opId"_attr = opId, + "printKnownOps_inlock"_attr = printKnownOps_inlock()); iScope->second->kill(); } @@ -147,7 +156,11 @@ void MozJSScriptEngine::registerOperation(OperationContext* opCtx, MozJSImplScop _opToScopeMap[opId] = scope; - LOG(2) << "SMScope " << reinterpret_cast<uint64_t>(scope) << " registered for op " << opId; + LOGV2_DEBUG(22785, + 2, + "SMScope {reinterpret_cast_uint64_t_scope} registered for op {opId}", + "reinterpret_cast_uint64_t_scope"_attr = reinterpret_cast<uint64_t>(scope), + "opId"_attr = opId); Status status = opCtx->checkForInterruptNoAssert(); if (!status.isOK()) { scope->kill(); @@ -157,7 +170,11 @@ void MozJSScriptEngine::registerOperation(OperationContext* opCtx, MozJSImplScop void MozJSScriptEngine::unregisterOperation(unsigned int opId) { stdx::lock_guard<Latch> giLock(_globalInterruptLock); - LOG(2) << "ImplScope " << reinterpret_cast<uint64_t>(this) << " unregistered for op " << opId; + LOGV2_DEBUG(22786, + 2, + "ImplScope {reinterpret_cast_uint64_t_this} unregistered for op {opId}", + "reinterpret_cast_uint64_t_this"_attr = reinterpret_cast<uint64_t>(this), + "opId"_attr = opId); if (opId != 0) { // scope is currently associated with an operation id diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp index 7c2f57a04ef..75f4a902a37 100644 --- a/src/mongo/scripting/mozjs/implscope.cpp +++ b/src/mongo/scripting/mozjs/implscope.cpp @@ -43,6 +43,7 @@ #include "mongo/base/error_codes.h" #include "mongo/config.h" #include "mongo/db/operation_context.h" +#include "mongo/logv2/log.h" #include "mongo/platform/decimal128.h" #include "mongo/platform/mutex.h" #include "mongo/platform/stack_locator.h" @@ -224,8 +225,13 @@ void MozJSImplScope::_gcCallback(JSContext* rt, JSGCStatus status, void* data) { return; } - log() << "MozJS GC " << (status == JSGC_BEGIN ? "prologue" : "epilogue") << " heap stats - " - << " total: " << mongo::sm::get_total_bytes() << " limit: " << mongo::sm::get_max_bytes(); + LOGV2(22787, + "MozJS GC {status_JSGC_BEGIN_prologue_epilogue} heap stats - total: " + "{mongo_sm_get_total_bytes} limit: {mongo_sm_get_max_bytes}", + "status_JSGC_BEGIN_prologue_epilogue"_attr = + (status == JSGC_BEGIN ? "prologue" : "epilogue"), + "mongo_sm_get_total_bytes"_attr = mongo::sm::get_total_bytes(), + "mongo_sm_get_max_bytes"_attr = mongo::sm::get_max_bytes()); } #if __has_feature(address_sanitizer) @@ -275,7 +281,8 @@ MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine, jsHeapLimitMB ? std::min(*jsHeapLimitMB, engineJsHeapLimit) : engineJsHeapLimit; if (jsHeapLimit != 0 && jsHeapLimit < 10) { - warning() << "JavaScript may not be able to initialize with a heap limit less than 10MB."; + LOGV2_WARNING(22788, + "JavaScript may not be able to initialize with a heap limit less than 10MB."); } size_t mallocMemoryLimit = 1024ul * 1024 * jsHeapLimit; mongo::sm::reset(mallocMemoryLimit); @@ -699,7 +706,7 @@ int MozJSImplScope::invoke(ScriptingFunction func, // must validate the handle because TerminateExecution may have // been thrown after the above checks if (out.isObject() && _nativeFunctionProto.instanceOf(out)) { - warning() << "storing native function as return value"; + LOGV2_WARNING(22789, "storing native function as return value"); _lastRetIsNativeCode = true; } else { _lastRetIsNativeCode = false; diff --git a/src/mongo/scripting/mozjs/session.cpp b/src/mongo/scripting/mozjs/session.cpp index f1353742344..cc7eaa204af 100644 --- a/src/mongo/scripting/mozjs/session.cpp +++ b/src/mongo/scripting/mozjs/session.cpp @@ -33,6 +33,7 @@ #include "mongo/scripting/mozjs/session.h" +#include "mongo/logv2/log.h" #include "mongo/scripting/mozjs/bson.h" #include "mongo/scripting/mozjs/implscope.h" #include "mongo/scripting/mozjs/mongo.h" @@ -152,7 +153,10 @@ void SessionInfo::finalize(js::FreeOp* fop, JSObject* obj) { auto status = exceptionToStatus(); try { - LOG(0) << "Failed to end session " << lsid << " due to " << status; + LOGV2(22791, + "Failed to end session {lsid} due to {status}", + "lsid"_attr = lsid, + "status"_attr = status); } catch (...) { // This is here in case logging fails. } |