Add function for profile loggin in release (#5018)

This commit is contained in:
Panayot Cankov
2017-11-01 13:24:57 +02:00
committed by GitHub
parent 3e6f465cc8
commit f1c33d2420
2 changed files with 14 additions and 1 deletions

View File

@ -128,3 +128,8 @@ export declare function stopCPUProfile(name: string): void;
* Gets the uptime of the current process in milliseconds. * Gets the uptime of the current process in milliseconds.
*/ */
export function uptime(): number; export function uptime(): number;
/**
* Logs important messages. Contrary to console.log's behavior, the profiling log should output even for release builds.
*/
export function log(message: string): void;

View File

@ -7,6 +7,14 @@ export function uptime() {
return global.android ? (<any>org).nativescript.Process.getUpTime() : (<any>global).__tns_uptime(); return global.android ? (<any>org).nativescript.Process.getUpTime() : (<any>global).__tns_uptime();
} }
export function log(message: string): void {
if ((<any>global).__nslog) {
(<any>global).__nslog("CONSOLE LOG: " + message);
} else {
console.log(message);
}
}
interface TimerInfo extends TimerInfoDefinition { interface TimerInfo extends TimerInfoDefinition {
totalTime: number; totalTime: number;
lastTime?: number; lastTime?: number;