зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1687553 - Make more `dump` implementations log to MOZ_LOG system under module "Dump". r=xpcom-reviewers,nika
This is an extension of the existing implementations added by Bug 1059469. By extension, this makes `console.log` and friends log to the MOZ_LOG system when `browser.dom.window.dump.enabled` is true. My immediate use case is capturing cumulative logs for the new `--backgroundtask ...` mode that will be used to invoke maintenance tasks when Firefox itself is not running. This will lead to duplicate messages (from both the MOZ_LOG system and `fputs`) when the MOZ_LOG system is not redirected but there's no particular harm in that. In the future, we could not `fputs` when the MOZ_LOG system will log the given message, but it seems better to actually do the work to connect the `Log.jsm` and `ConsoleAPI.jsm` systems to MOZ_LOG rather than continue to add work arounds. Differential Revision: https://phabricator.services.mozilla.com/D104636
This commit is contained in:
Родитель
1fe1bca9b7
Коммит
20e71161ca
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/MessageManagerGlobal.h"
|
||||
#include "mozilla/IntentionalCrash.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsJSUtils.h"
|
||||
|
||||
|
@ -23,16 +24,18 @@ void MessageManagerGlobal::Dump(const nsAString& aStr) {
|
|||
return;
|
||||
}
|
||||
|
||||
NS_ConvertUTF16toUTF8 cStr(aStr);
|
||||
MOZ_LOG(nsContentUtils::DOMDumpLog(), mozilla::LogLevel::Debug,
|
||||
("[MessageManager.Dump] %s", cStr.get()));
|
||||
#ifdef ANDROID
|
||||
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s",
|
||||
NS_ConvertUTF16toUTF8(aStr).get());
|
||||
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", cStr.get());
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
if (IsDebuggerPresent()) {
|
||||
OutputDebugStringW(PromiseFlatString(aStr).get());
|
||||
}
|
||||
#endif
|
||||
fputs(NS_ConvertUTF16toUTF8(aStr).get(), stdout);
|
||||
fputs(cStr.get(), stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "mozilla/dom/WorkletImpl.h"
|
||||
#include "mozilla/dom/WorkletThread.h"
|
||||
#include "mozilla/dom/Console.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsJSUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -80,10 +81,11 @@ void WorkletGlobalScope::Dump(const Optional<nsAString>& aString) const {
|
|||
|
||||
NS_ConvertUTF16toUTF8 str(aString.Value());
|
||||
|
||||
MOZ_LOG(nsContentUtils::DOMDumpLog(), mozilla::LogLevel::Debug,
|
||||
("[Worklet.Dump] %s", str.get()));
|
||||
#ifdef ANDROID
|
||||
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", str.get());
|
||||
#endif
|
||||
|
||||
fputs(str.get(), stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
|
|
@ -121,6 +121,8 @@ static bool Dump(JSContext* cx, unsigned argc, Value* vp) {
|
|||
return false;
|
||||
}
|
||||
|
||||
MOZ_LOG(nsContentUtils::DOMDumpLog(), mozilla::LogLevel::Debug,
|
||||
("[Backstage.Dump] %s", utf8str.get()));
|
||||
#ifdef ANDROID
|
||||
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", utf8str.get());
|
||||
#endif
|
||||
|
|
|
@ -177,10 +177,11 @@ static bool SandboxDump(JSContext* cx, unsigned argc, Value* vp) {
|
|||
c++;
|
||||
}
|
||||
#endif
|
||||
MOZ_LOG(nsContentUtils::DOMDumpLog(), mozilla::LogLevel::Debug,
|
||||
("[Sandbox.Dump] %s", cstr));
|
||||
#ifdef ANDROID
|
||||
__android_log_write(ANDROID_LOG_INFO, "GeckoDump", cstr);
|
||||
#endif
|
||||
|
||||
fputs(cstr, stdout);
|
||||
fflush(stdout);
|
||||
args.rval().setBoolean(true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче