Skip to content

Commit f1c33d2

Browse files
Add function for profile loggin in release (NativeScript#5018)
1 parent 3e6f465 commit f1c33d2

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

tns-core-modules/profiling/profiling.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,8 @@ export declare function stopCPUProfile(name: string): void;
128128
* Gets the uptime of the current process in milliseconds.
129129
*/
130130
export function uptime(): number;
131+
132+
/**
133+
* Logs important messages. Contrary to console.log's behavior, the profiling log should output even for release builds.
134+
*/
135+
export function log(message: string): void;

tns-core-modules/profiling/profiling.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ export function uptime() {
77
return global.android ? (<any>org).nativescript.Process.getUpTime() : (<any>global).__tns_uptime();
88
}
99

10+
export function log(message: string): void {
11+
if ((<any>global).__nslog) {
12+
(<any>global).__nslog("CONSOLE LOG: " + message);
13+
} else {
14+
console.log(message);
15+
}
16+
}
17+
1018
interface TimerInfo extends TimerInfoDefinition {
1119
totalTime: number;
1220
lastTime?: number;
@@ -285,4 +293,4 @@ export function stopCPUProfile(name: string) {
285293
if (anyGlobal.android) {
286294
__stopCPUProfiler(name);
287295
}
288-
}
296+
}

0 commit comments

Comments
 (0)