@@ -158,6 +158,9 @@ const std::string buildLogString(const v8::FunctionCallbackInfo<v8::Value>& info
158158}
159159
160160void Console::assertCallback (const v8::FunctionCallbackInfo<v8::Value>& info) {
161+ if (!isApplicationInDebug) {
162+ return ;
163+ }
161164 try {
162165 auto isolate = info.GetIsolate ();
163166
@@ -193,6 +196,9 @@ void Console::assertCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
193196}
194197
195198void Console::errorCallback (const v8::FunctionCallbackInfo <v8::Value>& info) {
199+ if (!isApplicationInDebug) {
200+ return ;
201+ }
196202 try {
197203 std::string log = buildLogString (info);
198204
@@ -212,6 +218,9 @@ void Console::errorCallback(const v8::FunctionCallbackInfo <v8::Value>& info) {
212218}
213219
214220void Console::infoCallback (const v8::FunctionCallbackInfo<v8::Value>& info) {
221+ if (!isApplicationInDebug) {
222+ return ;
223+ }
215224 try {
216225 std::string log = buildLogString (info);
217226
@@ -231,6 +240,9 @@ void Console::infoCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
231240}
232241
233242void Console::logCallback (const v8::FunctionCallbackInfo<v8::Value>& info) {
243+ if (!isApplicationInDebug) {
244+ return ;
245+ }
234246 try {
235247 std::string log = buildLogString (info);
236248
@@ -250,6 +262,9 @@ void Console::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
250262}
251263
252264void Console::warnCallback (const v8::FunctionCallbackInfo<v8::Value>& info) {
265+ if (!isApplicationInDebug) {
266+ return ;
267+ }
253268 try {
254269 std::string log = buildLogString (info);
255270
@@ -269,6 +284,9 @@ void Console::warnCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
269284}
270285
271286void Console::dirCallback (const v8::FunctionCallbackInfo<v8::Value>& info) {
287+ if (!isApplicationInDebug) {
288+ return ;
289+ }
272290 try {
273291 auto isolate = info.GetIsolate ();
274292 auto context = isolate->GetCurrentContext ();
@@ -383,6 +401,9 @@ const std::string buildStacktraceFrameMessage(v8::Local<v8::StackFrame> frame) {
383401}
384402
385403void Console::traceCallback (const v8::FunctionCallbackInfo<v8::Value>& info) {
404+ if (!isApplicationInDebug) {
405+ return ;
406+ }
386407 try {
387408 auto isolate = info.GetIsolate ();
388409 std::stringstream ss;
@@ -426,6 +447,9 @@ void Console::traceCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
426447}
427448
428449void Console::timeCallback (const v8::FunctionCallbackInfo<v8::Value>& info) {
450+ if (!isApplicationInDebug) {
451+ return ;
452+ }
429453 try {
430454 auto isolate = info.GetIsolate ();
431455
@@ -462,6 +486,9 @@ void Console::timeCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
462486}
463487
464488void Console::timeEndCallback (const v8::FunctionCallbackInfo<v8::Value>& info) {
489+ if (!isApplicationInDebug) {
490+ return ;
491+ }
465492 try {
466493 auto isolate = info.GetIsolate ();
467494
@@ -520,4 +547,10 @@ void Console::timeEndCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
520547const char * Console::LOG_TAG = " JS" ;
521548std::map<v8::Isolate*, std::map<std::string, double >> Console::s_isolateToConsoleTimersMap;
522549ConsoleCallback Console::m_callback = nullptr ;
550+
551+ #ifdef APPLICATION_IN_DEBUG
552+ bool Console::isApplicationInDebug = true ;
553+ #else
554+ bool Console::isApplicationInDebug = false ;
555+ #endif
523556}
0 commit comments