Repository navigation
ADFA-1079 | Add Native Logging Demos template bundle (C and C++) - #143
Open
jimturner-adfa wants to merge 3 commits into
Open
jimturner-adfa wants to merge 3 commits into
jimturner-adfa wants to merge 3 commits into
Conversation
Verbatim copy of EmptyActivity from core.cgt into NativeLogDemoC and NativeLogDemoCpp, no changes. The next commit turns both into the demos, so its diff shows only what they add. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two templates that show how to write to the App Logs window from native code. Each has one button that calls runDemo() over JNI. - Native Log Demo (C): C11. LOGx macros over __android_log_print, __android_log_write, a __android_log_vprint wrapper, a printf-checked helper that adds __func__/__LINE__, errno reporting, a pthread worker. - Native Log Demo (C++): C++17. A type-safe operator<< logger, an RAII scope timer, structured bindings, a custom type with a stream operator, an exception's what(), a std::thread worker. Natives are bound with RegisterNatives in JNI_OnLoad rather than Java_<package>_ names, which break for a package containing '_'. FATAL is left out because App Logs does not parse the F level. Both need the NDK-Installer plugin; ndkVersion and arm64-v8a match what it installs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The gallery page said Extensions Manager; the current build labels the screen Add-ons Manager. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ADFA-1079
Adds
templates/Native-Logging-Demos, a template bundle with two projects that write to Code on the Go's App Logs window from native code. Each has one button that callsrunDemo()over JNI. Kotlin or Java for the activity.LOGxmacros over__android_log_print,__android_log_write, a__android_log_vprintwrapper, a printf-checked helper adding__func__/__LINE__,errnoreporting, apthreadworkerlogx::info() << ...logger, RAII scope timer, structured bindings, a custom type withoperator<<, an exception'swhat(), astd::threadworkerReview by commit
877c043- verbatim copy ofEmptyActivityfromcore.cgtinto both templates. Skim.a7abde9- the demos: native sources, CMake,externalNativeBuild, layout, strings, metadata, gallery page, icons.5299df6- gallery page names the screen Add-ons Manager, as the app labels it.Design choices
RegisterNativesinJNI_OnLoadinstead ofJava_<package>_...names. Those need_1mangling for a package containing_, which a template cannot apply (the NDK-Installer template has this bug). Rejected: documenting "no underscores in the package".ANDROID_LOG_FATAL- App Logs does not recogniseFand shows the line as raw text.ndkVersion = "29.0.14206865"andarm64-v8amatch what it installs.Testing
On a Pixel 6 Pro (arm64, API 37), Code on the Go
C-d-1014-1359, NDK-Installer plugin installed:.cgtvia Add-ons Manager; the dialog lists both templates in order.com.example.native_log_cpp) and C/Java (com.example.native_log_c): no.pebsuffixes, notemplate/dir, other language dropped.JNI_OnLoadregistration works with the underscore packages).-Wall -Wextra -Wpedantic -Werrorfor API 21/26/35; all four template x language combinations build debug and release offline, and release keepsrunDemothrough R8.addons checkpasses;build-templates.sh Native-Logging-Demosbuilds.Observed, not caused by this PR: on one of the two runs App Logs omitted the app's first ~0.5 s of output (including the demo's
Library loadedline), which was present in logcat. Likely a timing issue in LogSender's first delivery.🤖 Generated with Claude Code