Package -
Akadenia Logger
Wrapper library for logging to different services
Installation
npm install @akadenia/logger --save
Getting Started
- Create a
log.ts
file in your project - Initiate a class where we can customize our logger
- Attach the desired adapter (here we're demonstrating how to use @sentry/react-native adapter).
import * as Sentry from "@sentry/react-native"
import { Config, Logger, SentryAdapter, Severity } from "@akadenia/logger"
import { APP_ENV, SENTRY_DSN } from "react-native-dotenv"
class Log extends Logger {
constructor(defaultConfig?: Config, minimumLogLevel?: Severity) {
super(defaultConfig, minimumLogLevel)
Sentry.init({
dsn: SENTRY_DSN,
enabled: APP_ENV === "prd",
})
this.addLogger(new SentryAdapter(Sentry))
}
}
export default new Log(
{
console: true,
},
__DEV__ ? Severity.Debug : Severity.Error,
)
Usage example
import Log from "../log.ts"
Log.debug("Hello World")
Supported Adapters
- Sentry
- Signoz