Sentry transporter seems to log always to error despite using info/debug..
Closed this issue · 2 comments
samih-dev commented
Hi
Appreciate the work done with this package, thanks!
seems that sentry transporter is logging to error level always despite using info/debug/...
please help
thx
topi-identio commented
We ended up using a custom implementation for Sentry
const customSentryTransport: transportFunctionType = props => {
if (!props.options?.SENTRY) {
throw Error('No sentry instance provided');
}
if (props.level.text === 'error') {
// Capture error
props.options.SENTRY.captureException(...);
return true;
}
// Otherwise log as breadcrumb
props.options.SENTRY.addBreadcrumb(...);
return true;
};
alessandro-bottamedi commented
I added the ability to specify which levels to treat as errors in the Sentry transport, so that even custom levels can be treated as errors, while all other logs are handled as breadcrumbs, meaning logs tied to the next error. 1c9488a
Example:
import { logger, sentryTransport } from "react-native-logs";
import * as Sentry from "@sentry/react-native";
/*
* Configure sentry
*/
const config = {
severity: "debug",
transport: sentryTransport,
transportOptions: {
SENTRY: Sentry,
errorLeves: "error",
},
};
var log = logger.createLogger(config);
log.warn("Send this log to Sentry as breadcumb");
log.error("Send this log to Sentry as error");