logs
Feature Introduction
Print logs in the SDK Core format.
The logLevel
indicates the severity of the logs: when logLevel
is 6, it prints Debug logs with SQL statements; when logLevel
is 5, it prints Debug logs; when logLevel
is 4, it prints Info logs; when logLevel
is 3, it prints Warn logs; and when logLevel
is 2, it prints Error logs.
The file
parameter refers to the relative path of the file where the log printing interface is called, line
indicates the specific line number in the file, msg
is a custom description of the current log, err
is the expected error to be passed in, and keyAndValues
contains key-value pairs describing additional fields to be printed along with their values.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
@openim/client-sdk
and @openim/wasm-client-sdk
This method is not provided. It is introduced only in electron @openim/electron-client-sdk
It can be invoked only when the ffi mode is adopted。
Function Prototype
IMSDK.logs({
logLevel: number,
file: string,
line: number,
msgs: string,
err: string,
keyAndValue: string
}, operationID?: string): Promise<WsResponse>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
logLevel | number | No | logLevel |
file | string | No | file |
line | number | No | line |
msgs | string | No | message |
err | string | No | err |
keyAndValues | string | No | Values |
operationID | string | No | Operation ID, which is used to locate the problem. Keep it unique. You are advised to use the current time and random number |
Return Result
Name | Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse> | Success return |
Promise.catch() | Promise<WsResponse> | Failure return |
Code Example
// use in electron with ffi
import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
const { instance: IMSDK } = getWithRenderProcess();
IMSDK.logs({
logLevel: 5,
file: 'file',
line: 10,
msgs: 'msgs',
err: 'err',
keyAndValue: 'keyAndValue'
})
.then(() => {
// success
})
.catch(({ errCode, errMsg }) => {
// failure
});
Function Prototype
IMSDK.asyncApi('logs', operationID: string, {
logLevel: number,
file: string,
line: number,
msgs: string,
err: string,
keyAndValue: string
}): Promise<void>
Return Result
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
logLevel | number | No | logLevel |
file | string | No | file |
line | number | No | line |
msgs | string | No | message |
err | string | No | err |
keyAndValues | string | No | Values |
operationID | string | Yes | Operation ID, which is used to locate the problem. Keep it unique. You are advised to use the current time and random number |
Return Result
Name | Type | Description |
---|---|---|
Promise.then() | Promise<void> | Success return |
Promise.catch() | Promise<CatchResponse> | Failure return |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('logs', IMSDK.uuid(), {
logLevel: 5,
file: 'file',
line: 10,
msgs: 'msgs',
err: 'err',
keyAndValue: 'keyAndValue'
})
.then(() => {
// success
})
.catch(({ errCode, errMsg }) => {
// failure
});
Function Prototype
OpenIMSDKRN.logs({
logLevel: number,
file: string,
line: number,
msgs: string,
err: string,
keyAndValue: string
}, operationID: string): Promise<void>
Return Result
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
logLevel | number | No | logLevel |
file | string | No | file |
line | number | No | line |
msgs | string | No | message |
err | string | No | err |
keyAndValues | string | No | Values |
operationID | string | Yes | Operation ID, which is used to locate the problem. Keep it unique. You are advised to use the current time and random number |
Return Result
Name | Type | Description |
---|---|---|
Promise.then() | Promise<void> | Success return |
Promise.catch() | Promise<CatchResponse> | Failure return |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.logs({
logLevel: 5,
file: 'file',
line: 10,
msgs: 'msgs',
err: 'err',
keyAndValue: 'keyAndValue'
}, 'operationID')
.then(() => {
// success
})
.catch(({ errCode, errMsg }) => {
// failure
});