Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CMPOSLogger from public API #1652

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END

void CMPOSInitializeAppTraceLogger(NSString * _Nonnull name);
CMPOSLogger * _Nullable CMPOSAppTraceLogger(void);
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,13 @@ - (void)endInterval:(CMPOSLoggerInterval *)interval {


@end

static CMPOSLogger *_globalAppTraceLogger = nil;

void CMPOSInitializeAppTraceLogger(NSString *name) {
_globalAppTraceLogger = [[CMPOSLogger alloc] initWithCategoryName:name];
}

CMPOSLogger * _Nullable CMPOSAppTraceLogger(void) {
return _globalAppTraceLogger;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,26 @@

package androidx.compose.ui.util

import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.uikit.utils.CMPOSLogger
import androidx.compose.ui.uikit.utils.CMPOSAppTraceLogger
import androidx.compose.ui.uikit.utils.CMPOSInitializeAppTraceLogger

/**
* Enables iOS OS logging for the `androidx.compose.ui` APIs.
*
* Tracing allows logging detailed information about the Compose UI framework, which can be further
* analyzed using the XCode Instruments tool.
*
* This method is an [ExperimentalComposeUiApi], which means it is subject to change without notice in major, minor, or patch releases.
*
* @see ExperimentalComposeUiApi
*/
@OptIn(InternalComposeUiApi::class)
@ExperimentalComposeUiApi
fun enableTraceOSLog() {
if (traceImpl == null) {
traceImpl = CMPOSLogger(categoryName = "androidx.compose.ui")
}
CMPOSInitializeAppTraceLogger(name = "androidx.compose.ui")
}

/**
* Instance of the [CMPOSLogger] used for tracing. Public due to `inline` requirement of [trace].
* Intended for internal use only.
*/
@InternalComposeUiApi
var traceImpl: CMPOSLogger? = null

@OptIn(InternalComposeUiApi::class)
actual inline fun <T> trace(sectionName: String, block: () -> T): T {
val interval = traceImpl?.beginIntervalNamed(sectionName)
val interval = CMPOSAppTraceLogger()?.beginIntervalNamed(sectionName)
try {
return block()
} finally {
interval?.let {
traceImpl?.endInterval(it)
CMPOSAppTraceLogger()?.endInterval(it)
}
}
}
}
Loading