@cap-kit/test-plugin 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -31
- package/android/src/main/java/io/capkit/test/Test.kt +48 -7
- package/android/src/main/java/io/capkit/test/TestConfig.kt +39 -4
- package/android/src/main/java/io/capkit/test/TestPlugin.kt +65 -9
- package/android/src/main/java/io/capkit/test/utils/Logger.kt +85 -0
- package/android/src/main/java/io/capkit/test/utils/TestUtils.kt +14 -0
- package/dist/docs.json +57 -21
- package/dist/esm/definitions.d.ts +137 -35
- package/dist/esm/definitions.js +23 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +4 -16
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +16 -27
- package/dist/esm/web.js +25 -28
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +54 -39
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +54 -39
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/TestPlugin/Test.swift +40 -8
- package/ios/Sources/TestPlugin/TestConfig.swift +52 -9
- package/ios/Sources/TestPlugin/TestPlugin.swift +83 -34
- package/ios/Sources/TestPlugin/Utils/Logging.swift +57 -0
- package/ios/Sources/TestPlugin/Utils/TestUtils.swift +12 -0
- package/package.json +9 -9
- package/android/src/main/java/io/capkit/test/Logger.kt +0 -25
- package/ios/Sources/TestPlugin/Logging.swift +0 -32
package/README.md
CHANGED
|
@@ -45,9 +45,10 @@ npx cap sync
|
|
|
45
45
|
|
|
46
46
|
Configuration options for the Test plugin.
|
|
47
47
|
|
|
48
|
-
| Prop
|
|
49
|
-
|
|
|
50
|
-
| **`customMessage`**
|
|
48
|
+
| Prop | Type | Description | Default | Since |
|
|
49
|
+
| -------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | ----- |
|
|
50
|
+
| **`customMessage`** | <code>string</code> | Custom message appended to the echoed value. This option exists mainly as an example showing how to pass static configuration data from JavaScript to native platforms. | <code>" (from config)"</code> | 0.0.1 |
|
|
51
|
+
| **`verboseLogging`** | <code>boolean</code> | Enables verbose native logging. When enabled, additional debug information is printed to the native console (Logcat on Android, Xcode on iOS). This option affects native logging behavior only and has no impact on the JavaScript API. | <code>false</code> | 1.0.0 |
|
|
51
52
|
|
|
52
53
|
### Examples
|
|
53
54
|
|
|
@@ -57,7 +58,8 @@ In `capacitor.config.json`:
|
|
|
57
58
|
{
|
|
58
59
|
"plugins": {
|
|
59
60
|
"Test": {
|
|
60
|
-
"customMessage": " - Hello from Config!"
|
|
61
|
+
"customMessage": " - Hello from Config!",
|
|
62
|
+
"verboseLogging": true
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
}
|
|
@@ -74,6 +76,7 @@ const config: CapacitorConfig = {
|
|
|
74
76
|
plugins: {
|
|
75
77
|
Test: {
|
|
76
78
|
customMessage: ' - Hello from Config!',
|
|
79
|
+
verboseLogging: true,
|
|
77
80
|
},
|
|
78
81
|
},
|
|
79
82
|
};
|
|
@@ -88,6 +91,7 @@ export default config;
|
|
|
88
91
|
<docgen-index>
|
|
89
92
|
|
|
90
93
|
* [`echo(...)`](#echo)
|
|
94
|
+
* [`openAppSettings()`](#openappsettings)
|
|
91
95
|
* [`getPluginVersion()`](#getpluginversion)
|
|
92
96
|
* [Interfaces](#interfaces)
|
|
93
97
|
|
|
@@ -96,7 +100,10 @@ export default config;
|
|
|
96
100
|
<docgen-api>
|
|
97
101
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
98
102
|
|
|
99
|
-
|
|
103
|
+
Public JavaScript API for the Test Capacitor plugin.
|
|
104
|
+
|
|
105
|
+
This interface defines a stable, platform-agnostic API.
|
|
106
|
+
All methods behave consistently across Android, iOS, and Web.
|
|
100
107
|
|
|
101
108
|
### echo(...)
|
|
102
109
|
|
|
@@ -106,12 +113,15 @@ echo(options: EchoOptions) => Promise<EchoResult>
|
|
|
106
113
|
|
|
107
114
|
Echoes the provided value.
|
|
108
115
|
|
|
109
|
-
If the plugin is configured with a `customMessage`,
|
|
110
|
-
to the
|
|
116
|
+
If the plugin is configured with a `customMessage`, that value
|
|
117
|
+
will be appended to the returned string.
|
|
118
|
+
|
|
119
|
+
This method is primarily intended as an example demonstrating
|
|
120
|
+
native ↔ JavaScript communication.
|
|
111
121
|
|
|
112
|
-
| Param | Type | Description
|
|
113
|
-
| ------------- | --------------------------------------------------- |
|
|
114
|
-
| **`options`** | <code><a href="#echooptions">EchoOptions</a></code> |
|
|
122
|
+
| Param | Type | Description |
|
|
123
|
+
| ------------- | --------------------------------------------------- | ------------------------------------ |
|
|
124
|
+
| **`options`** | <code><a href="#echooptions">EchoOptions</a></code> | Object containing the value to echo. |
|
|
115
125
|
|
|
116
126
|
**Returns:** <code>Promise<<a href="#echoresult">EchoResult</a>></code>
|
|
117
127
|
|
|
@@ -119,13 +129,29 @@ to the response.
|
|
|
119
129
|
|
|
120
130
|
#### Example
|
|
121
131
|
|
|
122
|
-
```
|
|
123
|
-
|
|
132
|
+
```ts
|
|
133
|
+
const { value } = await Test.echo({ value: 'Hello' });
|
|
134
|
+
console.log(value);
|
|
135
|
+
```
|
|
124
136
|
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
--------------------
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
### openAppSettings()
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
openAppSettings() => Promise<void>
|
|
127
144
|
```
|
|
128
145
|
|
|
146
|
+
Opens the operating system's application settings page.
|
|
147
|
+
|
|
148
|
+
This is typically used when a permission has been permanently
|
|
149
|
+
denied and the user must enable it manually.
|
|
150
|
+
|
|
151
|
+
On Web, this method is not supported.
|
|
152
|
+
|
|
153
|
+
**Since:** 1.0.0
|
|
154
|
+
|
|
129
155
|
--------------------
|
|
130
156
|
|
|
131
157
|
|
|
@@ -135,7 +161,10 @@ console.log(result.value); // Output: 'Hello, World!'
|
|
|
135
161
|
getPluginVersion() => Promise<PluginVersionResult>
|
|
136
162
|
```
|
|
137
163
|
|
|
138
|
-
|
|
164
|
+
Returns the native plugin version.
|
|
165
|
+
|
|
166
|
+
The returned version corresponds to the native implementation
|
|
167
|
+
bundled with the application.
|
|
139
168
|
|
|
140
169
|
**Returns:** <code>Promise<<a href="#pluginversionresult">PluginVersionResult</a>></code>
|
|
141
170
|
|
|
@@ -143,11 +172,8 @@ Get the native Capacitor plugin version.
|
|
|
143
172
|
|
|
144
173
|
#### Example
|
|
145
174
|
|
|
146
|
-
```
|
|
147
|
-
import { Test } from '@cap-kit/test-plugin';
|
|
148
|
-
|
|
175
|
+
```ts
|
|
149
176
|
const { version } = await Test.getPluginVersion();
|
|
150
|
-
console.log('Plugin version:', version); // Output: Plugin version: 0.0.1
|
|
151
177
|
```
|
|
152
178
|
|
|
153
179
|
--------------------
|
|
@@ -158,29 +184,35 @@ console.log('Plugin version:', version); // Output: Plugin version: 0.0.1
|
|
|
158
184
|
|
|
159
185
|
#### EchoResult
|
|
160
186
|
|
|
161
|
-
Result returned by the echo method.
|
|
187
|
+
Result object returned by the `echo` method.
|
|
162
188
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
189
|
+
This object represents the resolved value of the echo operation
|
|
190
|
+
after native processing has completed.
|
|
191
|
+
|
|
192
|
+
| Prop | Type | Description |
|
|
193
|
+
| ----------- | ------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
194
|
+
| **`value`** | <code>string</code> | The echoed string value. If a `customMessage` is configured, it will be appended to the original input value. |
|
|
166
195
|
|
|
167
196
|
|
|
168
197
|
#### EchoOptions
|
|
169
198
|
|
|
170
|
-
Options for the echo method.
|
|
199
|
+
Options object for the `echo` method.
|
|
200
|
+
|
|
201
|
+
This object defines the input payload sent from JavaScript
|
|
202
|
+
to the native plugin implementation.
|
|
171
203
|
|
|
172
|
-
| Prop | Type | Description
|
|
173
|
-
| ----------- | ------------------- |
|
|
174
|
-
| **`value`** | <code>string</code> | The value to be echoed. |
|
|
204
|
+
| Prop | Type | Description |
|
|
205
|
+
| ----------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
206
|
+
| **`value`** | <code>string</code> | The string value to be echoed back by the plugin. This value is passed to the native layer and returned unchanged, optionally with a configuration-based suffix. |
|
|
175
207
|
|
|
176
208
|
|
|
177
209
|
#### PluginVersionResult
|
|
178
210
|
|
|
179
|
-
Result returned by the getPluginVersion method.
|
|
211
|
+
Result object returned by the `getPluginVersion()` method.
|
|
180
212
|
|
|
181
|
-
| Prop | Type | Description
|
|
182
|
-
| ------------- | ------------------- |
|
|
183
|
-
| **`version`** | <code>string</code> | The native version string
|
|
213
|
+
| Prop | Type | Description |
|
|
214
|
+
| ------------- | ------------------- | --------------------------------- |
|
|
215
|
+
| **`version`** | <code>string</code> | The native plugin version string. |
|
|
184
216
|
|
|
185
217
|
</docgen-api>
|
|
186
218
|
|
|
@@ -1,20 +1,61 @@
|
|
|
1
1
|
package io.capkit.test
|
|
2
2
|
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import io.capkit.test.utils.Logger
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
|
-
*
|
|
7
|
+
* Platform-specific native implementation for the Test plugin.
|
|
8
|
+
*
|
|
9
|
+
* This class contains pure Android logic and MUST NOT depend
|
|
10
|
+
* directly on Capacitor bridge APIs.
|
|
5
11
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
12
|
+
* The Capacitor plugin class is responsible for:
|
|
13
|
+
* - reading configuration
|
|
14
|
+
* - handling PluginCall objects
|
|
15
|
+
* - delegating logic to this implementation
|
|
8
16
|
*/
|
|
9
|
-
class Test
|
|
17
|
+
class Test(
|
|
18
|
+
private val context: Context,
|
|
19
|
+
) {
|
|
10
20
|
/**
|
|
11
|
-
*
|
|
21
|
+
* Cached plugin configuration.
|
|
22
|
+
* Provided once during initialization.
|
|
23
|
+
*/
|
|
24
|
+
private lateinit var config: TestConfig
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Applies the plugin configuration.
|
|
12
28
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
29
|
+
* This method should be called exactly once during plugin load
|
|
30
|
+
* and is responsible for translating configuration values into
|
|
31
|
+
* runtime behavior (e.g. logging verbosity).
|
|
32
|
+
*/
|
|
33
|
+
fun updateConfig(newConfig: TestConfig) {
|
|
34
|
+
this.config = newConfig
|
|
35
|
+
Logger.verbose = this.config.verboseLogging
|
|
36
|
+
Logger.debug("Configuration updated. Verbose logging: ${this.config.verboseLogging}")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Echoes the provided value.
|
|
41
|
+
*
|
|
42
|
+
* This method represents a simple synchronous native operation
|
|
43
|
+
* and is intentionally side-effect free.
|
|
15
44
|
*/
|
|
16
45
|
fun echo(value: String): String {
|
|
17
46
|
Logger.debug(value)
|
|
18
47
|
return value
|
|
19
48
|
}
|
|
49
|
+
|
|
50
|
+
companion object {
|
|
51
|
+
/**
|
|
52
|
+
* Account type identifier (example constant).
|
|
53
|
+
*/
|
|
54
|
+
const val ACCOUNT_TYPE = "io.capkit.test"
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Human-readable account name (example constant).
|
|
58
|
+
*/
|
|
59
|
+
const val ACCOUNT_NAME = "Test"
|
|
60
|
+
}
|
|
20
61
|
}
|
|
@@ -1,16 +1,51 @@
|
|
|
1
1
|
package io.capkit.test
|
|
2
2
|
|
|
3
|
+
import android.content.Context
|
|
3
4
|
import com.getcapacitor.Plugin
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* Plugin configuration holder.
|
|
8
|
+
*
|
|
9
|
+
* This class is responsible for reading and parsing configuration values
|
|
10
|
+
* defined under the `Test` key in `capacitor.config.ts`.
|
|
11
|
+
*
|
|
12
|
+
* Configuration is read once during plugin initialization and treated as
|
|
13
|
+
* immutable runtime input.
|
|
8
14
|
*/
|
|
9
15
|
class TestConfig(plugin: Plugin) {
|
|
16
|
+
/**
|
|
17
|
+
* Android application context.
|
|
18
|
+
* Exposed for native components that may require it.
|
|
19
|
+
*/
|
|
20
|
+
val context: Context
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Enables verbose / debug logging for the plugin.
|
|
24
|
+
*
|
|
25
|
+
* When enabled, additional logs are printed to Logcat via [Logger.debug].
|
|
26
|
+
*
|
|
27
|
+
* Default: false
|
|
28
|
+
*/
|
|
29
|
+
val verboseLogging: Boolean
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Optional custom message appended to echoed values.
|
|
33
|
+
*
|
|
34
|
+
* This value is provided for demonstration purposes and shows how to
|
|
35
|
+
* pass static configuration from JavaScript to native code.
|
|
36
|
+
*/
|
|
10
37
|
val customMessage: String
|
|
11
38
|
|
|
12
39
|
init {
|
|
13
|
-
|
|
14
|
-
|
|
40
|
+
context = plugin.context
|
|
41
|
+
|
|
42
|
+
val config = plugin.getConfig()
|
|
43
|
+
|
|
44
|
+
// Parse verboseLogging (default: false)
|
|
45
|
+
verboseLogging = config.getBoolean("verboseLogging", false)
|
|
46
|
+
|
|
47
|
+
// Parse customMessage (default fallback applied)
|
|
48
|
+
val cm = config.getString("customMessage")
|
|
49
|
+
customMessage = if (cm.isNullOrBlank()) " (from config)" else cm
|
|
15
50
|
}
|
|
16
51
|
}
|
|
@@ -1,34 +1,57 @@
|
|
|
1
1
|
package io.capkit.test
|
|
2
2
|
|
|
3
|
+
import android.content.Intent
|
|
4
|
+
import android.net.Uri
|
|
5
|
+
import android.provider.Settings
|
|
6
|
+
import androidx.activity.result.ActivityResult
|
|
3
7
|
import com.getcapacitor.JSObject
|
|
4
8
|
import com.getcapacitor.Plugin
|
|
5
9
|
import com.getcapacitor.PluginCall
|
|
6
10
|
import com.getcapacitor.PluginMethod
|
|
11
|
+
import com.getcapacitor.annotation.ActivityCallback
|
|
7
12
|
import com.getcapacitor.annotation.CapacitorPlugin
|
|
13
|
+
import io.capkit.test.utils.Logger
|
|
8
14
|
|
|
9
15
|
/**
|
|
10
16
|
* Capacitor bridge for the Test plugin.
|
|
11
17
|
*
|
|
12
|
-
* This class
|
|
13
|
-
*
|
|
18
|
+
* This class acts as the boundary between JavaScript and native Android code.
|
|
19
|
+
* It is responsible for:
|
|
20
|
+
* - reading configuration
|
|
21
|
+
* - validating PluginCall input
|
|
22
|
+
* - mapping JS calls to native logic
|
|
14
23
|
*/
|
|
15
24
|
@CapacitorPlugin(
|
|
16
25
|
name = "Test",
|
|
17
26
|
)
|
|
18
27
|
class TestPlugin : Plugin() {
|
|
28
|
+
/**
|
|
29
|
+
* Plugin configuration parsed from capacitor.config.ts.
|
|
30
|
+
*/
|
|
19
31
|
private lateinit var config: TestConfig
|
|
20
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Native implementation containing platform logic.
|
|
35
|
+
*/
|
|
36
|
+
private lateinit var implementation: Test
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Called once when the plugin is loaded by the Capacitor bridge.
|
|
40
|
+
*
|
|
41
|
+
* This is the correct place to:
|
|
42
|
+
* - read configuration
|
|
43
|
+
* - initialize native resources
|
|
44
|
+
* - inject dependencies into the implementation
|
|
45
|
+
*/
|
|
21
46
|
override fun load() {
|
|
22
47
|
super.load()
|
|
23
|
-
|
|
48
|
+
|
|
24
49
|
config = TestConfig(this)
|
|
50
|
+
implementation = Test(context)
|
|
51
|
+
implementation.updateConfig(config)
|
|
25
52
|
}
|
|
26
53
|
|
|
27
|
-
|
|
28
|
-
private val pluginVersion: String = BuildConfig.PLUGIN_VERSION
|
|
29
|
-
|
|
30
|
-
/** Native implementation (business logic). */
|
|
31
|
-
private val implementation = Test()
|
|
54
|
+
// --- ---
|
|
32
55
|
|
|
33
56
|
/**
|
|
34
57
|
* Echoes a string back to JavaScript.
|
|
@@ -48,13 +71,46 @@ class TestPlugin : Plugin() {
|
|
|
48
71
|
call.resolve(ret)
|
|
49
72
|
}
|
|
50
73
|
|
|
74
|
+
// --- Version ---
|
|
75
|
+
|
|
51
76
|
/**
|
|
52
77
|
* Returns the plugin version.
|
|
53
78
|
*/
|
|
54
79
|
@PluginMethod
|
|
55
80
|
fun getPluginVersion(call: PluginCall) {
|
|
56
81
|
val ret = JSObject()
|
|
57
|
-
ret.put("version",
|
|
82
|
+
ret.put("version", BuildConfig.PLUGIN_VERSION)
|
|
58
83
|
call.resolve(ret)
|
|
59
84
|
}
|
|
85
|
+
|
|
86
|
+
// --- Settings ---
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Opens the application details settings page.
|
|
90
|
+
* Allowing the user to manually enable permissions.
|
|
91
|
+
*/
|
|
92
|
+
@PluginMethod
|
|
93
|
+
fun openAppSettings(call: PluginCall) {
|
|
94
|
+
try {
|
|
95
|
+
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
|
|
96
|
+
val uri = Uri.fromParts("package", context.packageName, null)
|
|
97
|
+
intent.data = uri
|
|
98
|
+
startActivityForResult(call, intent, "openSettingsResult")
|
|
99
|
+
call.resolve()
|
|
100
|
+
} catch (e: Exception) {
|
|
101
|
+
call.reject(
|
|
102
|
+
"Failed to open settings",
|
|
103
|
+
"UNAVAILABLE",
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@ActivityCallback
|
|
109
|
+
private fun openSettingsResult(
|
|
110
|
+
call: PluginCall,
|
|
111
|
+
result: ActivityResult,
|
|
112
|
+
) {
|
|
113
|
+
// No-op, just to satisfy the callback requirement if needed
|
|
114
|
+
call.resolve()
|
|
115
|
+
}
|
|
60
116
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
package io.capkit.test.utils
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Centralized logging utility for the Test plugin.
|
|
7
|
+
*
|
|
8
|
+
* This logger provides a single entry point for all native logs
|
|
9
|
+
* and supports runtime-controlled verbose logging.
|
|
10
|
+
*
|
|
11
|
+
* The goal is to avoid scattering `if (verbose)` checks across
|
|
12
|
+
* business logic and keep logging behavior consistent.
|
|
13
|
+
*/
|
|
14
|
+
object Logger {
|
|
15
|
+
/**
|
|
16
|
+
* Logcat tag used for all plugin logs.
|
|
17
|
+
* Helps filtering logs during debugging.
|
|
18
|
+
*/
|
|
19
|
+
private const val TAG = "⚡️ Test"
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Controls whether debug logs are printed.
|
|
23
|
+
*
|
|
24
|
+
* This flag should be set once during plugin initialization
|
|
25
|
+
* based on configuration values.
|
|
26
|
+
*/
|
|
27
|
+
var verbose: Boolean = false
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Prints a debug / verbose log message.
|
|
31
|
+
*
|
|
32
|
+
* This method should be used for development-time diagnostics
|
|
33
|
+
* and is automatically silenced when [verbose] is false.
|
|
34
|
+
*
|
|
35
|
+
* @param messages One or more message fragments to be concatenated.
|
|
36
|
+
*/
|
|
37
|
+
fun debug(vararg messages: String) {
|
|
38
|
+
if (verbose) {
|
|
39
|
+
log(TAG, Log.DEBUG, *messages)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Prints an error log message.
|
|
45
|
+
*
|
|
46
|
+
* Error logs are always printed regardless of [verbose] state.
|
|
47
|
+
*
|
|
48
|
+
* @param message Human-readable error description.
|
|
49
|
+
* @param e Optional exception for stack trace logging.
|
|
50
|
+
*/
|
|
51
|
+
fun error(
|
|
52
|
+
message: String,
|
|
53
|
+
e: Throwable? = null,
|
|
54
|
+
) {
|
|
55
|
+
val sb = StringBuilder(message)
|
|
56
|
+
if (e != null) {
|
|
57
|
+
sb.append(" | Error: ").append(e.message)
|
|
58
|
+
}
|
|
59
|
+
Log.e(TAG, sb.toString(), e)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Internal low-level log dispatcher.
|
|
64
|
+
*
|
|
65
|
+
* Joins message fragments and forwards them to Android's Log API
|
|
66
|
+
* using the specified priority.
|
|
67
|
+
*/
|
|
68
|
+
fun log(
|
|
69
|
+
tag: String,
|
|
70
|
+
level: Int,
|
|
71
|
+
vararg messages: String,
|
|
72
|
+
) {
|
|
73
|
+
val sb = StringBuilder()
|
|
74
|
+
for (msg in messages) {
|
|
75
|
+
sb.append(msg).append(" ")
|
|
76
|
+
}
|
|
77
|
+
when (level) {
|
|
78
|
+
Log.DEBUG -> Log.d(tag, sb.toString())
|
|
79
|
+
Log.INFO -> Log.i(tag, sb.toString())
|
|
80
|
+
Log.WARN -> Log.w(tag, sb.toString())
|
|
81
|
+
Log.ERROR -> Log.e(tag, sb.toString())
|
|
82
|
+
else -> Log.v(tag, sb.toString())
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package io.capkit.test.utils
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility helpers for the Test plugin.
|
|
5
|
+
*
|
|
6
|
+
* This object is intentionally empty and serves as a placeholder
|
|
7
|
+
* for future shared utility functions.
|
|
8
|
+
*
|
|
9
|
+
* Keeping a dedicated utils package helps maintain a clean
|
|
10
|
+
* separation between core logic and helper code.
|
|
11
|
+
*/
|
|
12
|
+
object TestUtils {
|
|
13
|
+
// Utilities will be added here as the plugin evolves
|
|
14
|
+
}
|