Settings
The logger requires a configuration object, LoggerConfig, containing important settings:
loggerConfig.ts
type LoggerConfig = {
AppName: string
Environment: {
IsDev: boolean
}
Slack: {
echo: {
channel?: string
icon: string
token: string
baseURL?: string
enabled?: boolean
options?: {
sendIn?: 'debug' | 'release'[]
include?: 'version'[]
}
}
}
Logger: {
ignoreLogs: string[]
performanceInspector: {
enabled: boolean
maxRenders: number
blacklist: string[]
}
}
Sentry: {
enabled: boolean
dsn: string
provider: any
debug?: boolean
initArgs?: any
beforeBreadcrumb?: any
}
}
AppName: The name of the application.IsDev: Indicates whether the app is running in a development environment.Slack:echo:channel: The Slack channel where logs should be sent.icon: The message icon.token: The unique Slack token.baseURL: The URL where the message will be sent. Defaults to https://slack.com/api/chat.postMessageenabled: If disabled, no logs will be sent.options:sendIn: Specifies in which mode the logs should be sent.include: Determines additional data to include in the log.
Logger:ignoreLogs: Specifies log messages that should be ignored and not displayed in the console.performanceInspector:enabled: Enables or disables performance logs.maxRenders: Maximum allowed renders before triggering an error.
Sentry:We recommend referring to the official Sentry documentation for more details.
enabled: Enables or disables log reporting to Sentry.dsn: The Sentry DSN URL.provider: The Sentry service provider.debug: Indicates whether debug mode is enabled.initArgs: Arguments passed to the Sentry initialization function.
Example Configuration
loggerConfig.ts
import DeviceInfo from 'react-native-device-info'
import * as Sentry from '@sentry/react-native'
export const Settings = {
AppName: 'Example',
Environment: {
IsDev: __DEV__,
},
Logger: {
performanceInspector: {
enabled: __DEV__,
maxRenders: 30,
blacklist: [],
},
ignoreLogs: [
`[react-native-gesture-handler] Seems like you're using`,
]
},
Slack: {
echo: {
icon: 'https://avatars.githubusercontent.com/u/23938?s=20&v=4',
token: 'TOKEN',
channel: '#logs',
options: {},
enabled: __DEV__,
},
},
Sentry: {
dsn: 'https://example.sd3343edsqe4c4e0@o10938498.ingest.sentry.io/234343',
enabled: !__DEV__,
provider: Sentry,
initArgs: {
environment: __DEV__ ? 'development' : 'production',
integrations: [Sentry.mobileReplayIntegration()],
replaysSessionSampleRate: 0.2,
release: `example@${DeviceInfo.getReadableVersion()}`,
dist: DeviceInfo.getBuildNumber(),
},
},
}