mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Expose __nslog that calls NSLog(@"%@", msg) under the hood so logs output can be performed in release builds
This commit is contained in:
@@ -9,9 +9,21 @@
|
|||||||
#ifndef TNSProcess_h
|
#ifndef TNSProcess_h
|
||||||
#define TNSProcess_h
|
#define TNSProcess_h
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the milliseconds since the process started.
|
* Get the milliseconds since the process started.
|
||||||
*/
|
*/
|
||||||
double __tns_uptime();
|
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 */
|
#endif /* TNSProcess_h */
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
#include "TNSProcess.h"
|
#include "TNSProcess.h"
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@@ -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;
|
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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user