diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-02-20 16:54:57 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-23 18:43:31 +0000 |
commit | e8f1d29de757d41f7d082d5ca1e667d1b8938741 (patch) | |
tree | 40a89fd7ef888cca91c413f4b5ecf981afcbdd99 /src/mongo/scripting | |
parent | 68dfffe822f1888f221b265dc7974e9f98ea383c (diff) | |
download | mongo-e8f1d29de757d41f7d082d5ca1e667d1b8938741.tar.gz |
SERVER-46156 Deprecate LogstreamBuilder and more manual log conversions
* Remove setPlainConsoleLogger()
* Update errorcodes linter to work with custom user defined log macros
rename src/mongo/embedded/{embedded_log_appender.h => embedded_log_backend.h} (61%)
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r-- | src/mongo/scripting/mozjs/global.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/mongo/scripting/mozjs/global.cpp b/src/mongo/scripting/mozjs/global.cpp index 391b1117c86..6092c560966 100644 --- a/src/mongo/scripting/mozjs/global.cpp +++ b/src/mongo/scripting/mozjs/global.cpp @@ -27,6 +27,8 @@ * it in the license file. */ +#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kDefault + #include "mongo/platform/basic.h" #include "mongo/scripting/mozjs/global.h" @@ -34,8 +36,7 @@ #include <js/Conversions.h> #include "mongo/base/init.h" -#include "mongo/logger/logger.h" -#include "mongo/logger/logstream_builder.h" +#include "mongo/logv2/log.h" #include "mongo/scripting/engine.h" #include "mongo/scripting/mozjs/implscope.h" #include "mongo/scripting/mozjs/jsstringwrapper.h" @@ -59,17 +60,8 @@ const JSFunctionSpec GlobalInfo::freeFunctions[7] = { const char* const GlobalInfo::className = "Global"; -namespace { - -logger::MessageLogDomain* plainShellOutputDomain; - -} // namespace - void GlobalInfo::Functions::print::call(JSContext* cx, JS::CallArgs args) { - logger::LogstreamBuilder builder( - plainShellOutputDomain, getThreadName(), logger::LogSeverity::Log()); - builder.setIsTruncatable(false); - std::ostream& ss = builder.stream(); + std::ostringstream ss; bool first = true; for (size_t i = 0; i < args.length(); i++) { @@ -87,9 +79,13 @@ void GlobalInfo::Functions::print::call(JSContext* cx, JS::CallArgs args) { JSStringWrapper jsstr(cx, JS::ToString(cx, args.get(i))); ss << jsstr.toStringData(); } - ss << std::endl; args.rval().setUndefined(); + + LOGV2_OPTIONS(4615635, + logv2::LogOptions(logv2::LogTag::kPlainShell, logv2::LogTruncation::Disabled), + "{message}", + "message"_attr = ss.str()); } void GlobalInfo::Functions::version::call(JSContext* cx, JS::CallArgs args) { @@ -127,10 +123,5 @@ void GlobalInfo::Functions::sleep::call(JSContext* cx, JS::CallArgs args) { args.rval().setUndefined(); } -MONGO_INITIALIZER(PlainShellOutputDomain)(InitializerContext*) { - plainShellOutputDomain = logger::globalLogManager()->getNamedDomain("plainShellOutput"); - return Status::OK(); -} - } // namespace mozjs } // namespace mongo |