From b55d27f78662b938fe3e04e43f3d177133499711 Mon Sep 17 00:00:00 2001 From: Panayot Cankov Date: Wed, 1 Nov 2017 10:14:00 +0200 Subject: [PATCH] Expose __nslog that calls NSLog(@"%@", msg) under the hood so logs output can be performed in release builds --- ios/TNSWidgets/TNSProcess.h | 12 ++++++++++++ ios/TNSWidgets/TNSProcess.m | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ios/TNSWidgets/TNSProcess.h b/ios/TNSWidgets/TNSProcess.h index 926beba96..baea95509 100644 --- a/ios/TNSWidgets/TNSProcess.h +++ b/ios/TNSWidgets/TNSProcess.h @@ -9,9 +9,21 @@ #ifndef TNSProcess_h #define TNSProcess_h +#import + /** * Get the milliseconds since the process started. */ double __tns_uptime(); +/** + * Provides access to NSLog. The runtime implementation of console.log is filtered in release. + * We rarely need to log in release but in cases such as when logging app startup times in release, + * this will be convenient shortcut to NSLog, NSLog is not exposed. + * + * Please note the {N} CLI may be filtering app output, prefixing the message with "CONSOLE LOG" + * will make the logs visible in "tns run ios --release" builds. + */ +void __nslog(NSString* message); + #endif /* TNSProcess_h */ diff --git a/ios/TNSWidgets/TNSProcess.m b/ios/TNSWidgets/TNSProcess.m index bfc5d3ce6..dc237b562 100644 --- a/ios/TNSWidgets/TNSProcess.m +++ b/ios/TNSWidgets/TNSProcess.m @@ -8,8 +8,6 @@ #include "TNSProcess.h" -#import - #include #include #include @@ -26,3 +24,7 @@ double __tns_uptime() { return (double)(current.tv_sec - proc.kp_proc.p_starttime.tv_sec) * 1000.0 + (double)(current.tv_usec - proc.kp_proc.p_starttime.tv_usec) / 1000.0; } + +void __nslog(NSString* message) { + NSLog(@"%@", message); +}