Log Configuration
Log Initialization Configuration
let logConfig: FTLogConfig = {
enableCustomLog: true,
enableLinkRumData: true,
};
await FTReactNativeLog.logConfig(logConfig);
| Field |
Type |
Required |
Description |
| sampleRate |
number |
No |
Sampling rate, value range [0,1]. 0 means no collection, 1 means full collection. Default is 1. |
| enableLinkRumData |
boolean |
No |
Whether to associate with RUM. |
| enableCustomLog |
boolean |
No |
Whether to enable custom logs. |
| logLevelFilters |
Array |
No |
Log level filters. |
| globalContext |
NSDictionary |
No |
Add custom tags for Log. For addition rules, please refer to here. |
| logCacheLimitCount |
number |
No |
Maximum number of log entries allowed in local cache [1000,). Larger logs mean greater disk cache pressure. Default is 5000. |
| discardStrategy |
enum FTLogCacheDiscard |
No |
Sets the discard rule when the log limit is reached. Default is FTLogCacheDiscard.discard. discard discards appended data, discardOldest discards oldest data. |
Logger Log Printing
Currently, the log content is limited to 30 KB. Characters exceeding this limit will be 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 |
Ok |