Log Configuration¶
Log Initialization Configuration¶
let logConfig: FTLogConfig = {
logSamplingRate: 100,
enableCustomLog: true,
enableLinkRumData: true,
};
await FTReactNativeLog.logConfig(logConfig);
| Field | Type | Required | Description |
|---|---|---|---|
| logSamplingRate | number | No | Sampling percentage, range [0,100], decimals supported, default 100. Takes precedence over sampleRate, including when explicitly set to 0. Supported since SDK 0.4.3. |
| sampleRate | number | No | Deprecated since SDK 0.4.3, retained for compatibility. Range [0,1], default 1; takes effect only when logSamplingRate is not set. Using logSamplingRate is recommended |
| enableLinkRumData | boolean | No | Whether to associate with RUM |
| enableCustomLog | boolean | No | Whether to enable custom logs |
| enableWebViewLog | boolean | No | Receives logs generated by the Browser Logs SDK in WebView, default false. Remote field logEnableWebViewLog can override the local switch. For details, see WebView Logs. Supported since SDK 0.4.3. |
| logLevelFilters | Array |
No | Log level filters |
| globalContext | NSDictionary | No | Add custom Log tags. For the addition rules, see here |
| logCacheLimitCount | number | No | Maximum number of log entries in the local cache [1000,). The larger the log volume, the greater the disk cache pressure. Default 5000 |
| discardStrategy | enum FTLogCacheDiscard | No | Sets the discard rule after logs reach the limit. Default FTLogCacheDiscard.discard. discard discards appended data; discardOldest discards old data |
SDK 0.4.3 and later support decimal percentage sampling. logSamplingRate: 12.5 means 12.5%, 1 means 1%, and 100 means full collection. For migration rules, see Sampling Configuration.
Logger Log Output¶
Currently, log content is limited to 30 KB. Characters exceeding this limit are truncated.
Usage¶
/**
* Outputs a log.
* @param content Log content
* @param logStatus Log status
* @param property Log context (optional)
*/
logging(content: String, logStatus: FTLogStatus | String, property?: object): Promise<void>;
Example¶
import { FTReactNativeLog, FTLogStatus } from '@cloudcare/react-native-mobile';
// logStatus: FTLogStatus
FTReactNativeLog.logging('info log content', FTLogStatus.info);
// logStatus: string
FTReactNativeLog.logging('info log content', 'info');
Log Levels¶
| Method Name | Meaning |
|---|---|
| FTLogStatus.info | Info |
| FTLogStatus.warning | Warning |
| FTLogStatus.error | Error |
| FTLogStatus.critical | Critical |
| FTLogStatus.ok | Recovery |