Skip to content

Commit f1c33d2

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

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy